Skip to content

Release 1

Preston Tranbarger edited this page Feb 20, 2019 · 23 revisions

Release 1

Constructor

Parameters

basicNeuralNet(nodes, learningRate)

The constructor passes 2 parameters: an array containing the amount of nodes in each layer, and a number that dictates the learning rate in stochastic gradient decent.

Example

nn = basicNeuralNet([2, 3, 1], 0.1)

This creates a object, called nn, of basicNeuralNet with 2 nodes in its input layer, 3 nodes in its 1st intermediate layer and 1 node in its output layer, and it sets the learning rate to be 0.1.

getNodes()

Parameters

getNodes()

There are no parameters for this method.

Return

This method returns the object’s stored value for the array nodes, an array which contains the number of nodes in each layer.

Example

nn = basicNeuralNet([2, 3, 1], 0.1)
print(nn.getNodes())

This prints:
[2, 3, 1]

getLearningRate()

Parameters

getLearningRate()

There are no parameters for this method.

Return

This method returns the objects stored value for the learning rate, a number which dictates the rate of stochastic gradient decent.

Example

nn = basicNeuralNet([2, 3, 1], 0.1)
print(nn.getLearningRate())

This prints:
0.1

setLearningRate()

Parameters

setLearningRate(learningRate)

This method passes 1 parameter: a number that dictates the learning rate in stochastic gradient decent.

Return

This method returns None.

Example

nn = basicNeuralNet([2, 3, 1], 0.1)
print(nn.getLearningRate())
nn.setLearningRate(0.01)
print(nn.getLearningRate())

This prints:

0.1
0.01

getWeights()

Parameters

getWeights()

There are no parameters for this method.

Return

This method returns the object's stored value for weights, an array containing the weight of each connection between nodes.

Example

nn = basicNeuralNet([1, 2, 1], 0.1)
print(nn.getWeights())

This could print (output varies based off of the values stored in the object's weight array):
[[[0.835734567971406], [0.21740565479821994]], [[0.6464352637609099, 0.10556332348227149]]]

For details of how the weight array is created, please look at the code in the init method.

getWeight()

Parameters

getWeight(location)

This method passes 1 parameter: an array for the location of the weight in the object's weight array that you would like to return.

Return

This method returns an array of sub arrays leading up to the final desired weight value in the last index of the output.

Example

nn = basicNeuralNet([1, 2, 1], 0.1)
print(nn.getWeight([0, 0, 0])

This could print (output varies based off of the values stored in the object's weight array):
[[[[0.9582632173156346], [0.6728321531385041]], [[0.05023917599931649, 0.9551830456872886]]], [[0.9582632173156346], [0.6728321531385041]], [0.9582632173156346], 0.9582632173156346]

For details of how the weight array is created, please look at the code in the init method.

setWeight()

Parameters

setWeight(location, value)

This method passes 2 parameters: an array for the location of the weight in the object's weight array that you would like to change, and a number for the value you would like to change that weight to.

Return

This method returns an array of sub arrays for the location in the same way as getWeight() but with the new modified value. The first index in the output array is the new value of that object's weight array.

Example

nn = basicNeuralNet([1, 2, 1], 0.1)
print(nn.getWeights())
print(nn.setWeight([0, 0, 0], 1))
print(nn.getWeights())

This could print (output varies based off of the values stored in the object's weight array):

[[[0.46745166694341644], [0.6013006799015506]], [[0.22937081238412904, 0.7712979142797524]]]
[[[[1], [0.6013006799015506]], [[0.22937081238412904, 0.7712979142797524]]], [[1], [0.6013006799015506]], [1], 1]
[[[1], [0.6013006799015506]], [[0.22937081238412904, 0.7712979142797524]]]

For details of how the weight array is created, please look at the code in the init method.

More coming later...

Released 2/15/19 by QPU Misaligned

Clone this wiki locally