Can any one explain how i can do this with c++???? Its an implementation of an artificial neuron in python. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can any one explain how i can do this with c++???? Its an implementation of an artificial neuron in python.

from numpy import exp, array, random, dot class neural_network: def __init__(self): random.seed(1) # 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 print(neural_network.think(array([15, 2])))

1st May 2020, 6:52 PM
OjileTheGenius
OjileTheGenius - avatar
2 Answers
+ 1
Please use the code for studying, I am sure you do so but also for those who views this post. ps: I created this 3 months ago, if you have any question about code, feel free to send pm. https://code.sololearn.com/cS2226l6JQw2/?ref=app
1st May 2020, 11:04 PM
Mustafa K.
Mustafa K. - avatar
0
Thanks mustapha k
2nd May 2020, 6:16 AM
OjileTheGenius
OjileTheGenius - avatar