I try to understand the work of neural networks through PHP using the appropriate extension using the example of an old article on Habré , after which the extension itself to work with FANN was rewritten (as I understood it) and started working differently. So I created a network using a spear method (because nothing is clearly described in the documentation):

$ann = fann_create_standard_array(3, array(256, 128, 3)); 

Then I try to learn it. And here there is a problem: the code that is specified in the article also does not work. Moreover, the fann_train function has changed and now, as a third argument, an array with "desired outputs" is needed. I don’t understand what it is (yes, I know how it is translated, but the translation does not add clarity). Here is how I tried to learn (again, at random):

 fann_train($ann, generate_frequencies(file_get_contents("en.txt")), array(1, 0, 0)); fann_train($ann, generate_frequencies(file_get_contents("ru.txt")), array(0, 1, 0)); fann_train($ann, generate_frequencies(file_get_contents("it.txt")), array(0, 0, 1)); 

It does not give errors and the "network" is saved to the file. Further, when trying to test a network with different languages, it produces the same probabilities. Ie, here is the code:

 fann_run($ann, generate_frequencies("Привет, мы будем счастливы теперь и навсегда.")); fann_run($ann, generate_frequencies("Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musi")); 

And everywhere are the same probabilities.

What am I doing wrong? How to make the network work?

PS The generate_frequencies function from the same article. Each file contains text of 10,000 characters in different languages.

  • do not torment php, pull yourself a python (seriously). - strangeqargo
  • @strangeqargo python I will definitely do, now there is no way to try a python for some reason. I want to try to figure out at least php. - devtwo

1 answer 1

The fann_train function now works differently. It produces only one iteration of learning. You need to place a learning block in a loop that will repeat 10,000 times.