def FeedForward(network, input): """ Arguments: --------- network : a NeuralNetwork instance input : an Input instance Returns: -------- Nothing Description: ----------- This function propagates the inputs through the network. That is, it modifies the *raw_value* and *transformed_value* attributes of the nodes in the network, starting from the input nodes. Notes: ----- The *input* arguments is an instance of Input, and contains just one attribute, *values*, which is a list of pixel values. The list is the same length as the number of input nodes in the network. i.e: len(input.values) == len(network.inputs) This is a distributed input encoding (see lecture notes 7 for more informations on encoding) In particular, you should initialize the input nodes using these input values: network.inputs[i].raw_value = input.values[i] """ network.CheckComplete() # 1) Assign input values to input nodes for i in range(0,len(input.values)): network.inputs[i].raw_value = input.values[i] network.inputs[i].transformed_value = input.values[i] # 2) Propagates to hidden layer for node in network.hidden_nodes: node.raw_value = NeuralNetwork.ComputeRawValue(node) node.transformed_value = NeuralNetwork.Sigmoid(node.raw_value) # 3) Propagates to the output layer for node in network.outputs: node.raw_value = NeuralNetwork.ComputeRawValue(node) node.transformed_value = NeuralNetwork.Sigmoid(node.raw_value) pass
def propagate_forward(nodes): for node in nodes: node.raw_value = NeuralNetwork.ComputeRawValue(node) node.transformed_value = NeuralNetwork.Sigmoid(node.raw_value)