I made a neural network which takes 2 input and gives out a number.
The output should be num1 - num2
But i am getting errors
And [nan] as output .
I had done almost everyrhing same as in tutorial given in python course neural network to predict number .
I only changed inputs and outputs plz help
Its not my code and also it is already public
You can find it under courses->python->more
Or i am just pasting here
from numpy import exp, array, random, dot
# We model a single neuron, with 3 inputs and 1 output and assign random weight.
self.weights = 2 * random.random((2, 1)) - 1
def train(self, inputs, outputs, num):
for iteration in range(num):
output = self.think(inputs)
error = outputs - output
adjustment = 0.01*dot(inputs.T, error)
self.weights += adjustment
def think(self, inputs):
return (dot(inputs, self.weights))
neural_network = neural_network()
# The training set
inputs = array([[2, 3], [1, 1], [5, 2], [12, 3]])
outputs = array([[10, 4, 14, 30]]).T
# Training the neural network using the training set.
neural_network.train(inputs, outputs, 10000)
# Ask the neural network the output
i made this code a while ago, but instead of subtraction , its addition.
edit: in java
important edit: its not addition.
given input : 10 and 20
my NNW multiplies both by 2 then adds them together, like so.... (2*10)+(2*20) = 60
sorry its been awile since ive looked at this code