Вопрос

I am using this code and try to predict the final number of a sequence.

The problem is that the neural network predict all the time float numbers.

Is there any way to fix the type of the sample? I want to test with integers, boolean and strings.

Thank you

Это было полезно?

Решение

To get an integer you simply round the float, probably expanding the range (if the output is in 0..1 and you want integers as up as 100 for example, multiply the returned value with 100 and round it afterwards).

To get booleans simply round the value to 0 or 1.

To get strings is tricky. If you know in advance what type of strings are expected you can tabulate them and use the above integer mechanism to get the index of the string to be returned. On the other hand, if you don't know the strings and want to create them dynamically at runtime, you're in for some big trouble: you will have to get each character in its own according to some grammar, possibly.

Edit: The other option is to have the output layer of the network consist of a layer of (usually softmax) neurons each one being responsible for a value of the output. For example, if you want to have only 10 integral outputs you'll have 10 output neurons and the one with the higher output will be the integer output. Something along the lines of competitive learning

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top