Reputation: 3
I am implementing a neural network which will take 225 input neurons and it has to classify random numbers from 1 to 7. So for this i need 225 random weights for first output. Suggest me what to do? I have to feed this to feed forward neural network
Upvotes: -1
Views: 205
Reputation: 7281
Note - I am assuming you are using a basic feed forward neural network with backprop. Please state otherwise if you are not.
You will essentially need two sets of weights, one set of weights for your hidden layers and one set of weights for your output layers.
Here is a basic function that should explain what I mean:
# Initialize a network
def initialize_network(n_inputs, hidden_nodes, n_outputs):
n_inputs = len(training_data[0]) - 1
n_outputs = len(set([row[-1] for row in training_data]))
# Create a blank list to hold the network
network = []
# Create your hidden layer
hidden_layer = [{'weights': [random() for i in range(n_inputs + 1)]} for i in range(hidden_nodes)]
# Append the hidden layer to your network list
network.append(hidden_layer)
# Create the output layer
output_layer = [{'weights': [random() for i in range(hidden_nodes + 1)]} for i in range(n_outputs)]
# Append that
network.append(output_layer)
# Return the network
return network
A couple of things to remember:
hidden_nodes
should be a tunable parameter or specified in your project instructions. The # of hidden nodes is different for everyoneUpvotes: 0