Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- adjustment = dot(training_set_inputs.T, error * self.__sigmoid_derivative(output)) ValueError: shapes (3,2736,1) and (1,2736,1) not aligned: 1 (dim 2) != 2736 (dim 1)
- Model | Trim | Cost
- 6 | 102 | 1200
- 8 | 105 | 1500
- 15 | 110 | 3000
- df = pd.read_csv('fulldata.csv')
- y = np.array(df[['Success']])
- y.reshape(y.size, 1)
- df.drop(['Success'],1 , inplace=True)
- t_in = df.values.tolist()
- class NeuralNetwork():
- def __init__(self):
- # Seed the random number generator
- random.seed(1)
- self.synaptic_weights = 2 * random.random((3,1)) - 1
- def __sigmoid(self, x):
- return 1 /(1 + exp(-x))
- def __sigmoid_derivative(self, x):
- return x * (1-x)
- def train(self, training_set_inputs, training_set_outputs, number_of_training_iterations):
- for iteration in xrange(number_of_training_iterations):
- output = self.predict(training_set_inputs)
- error = training_set_outputs - output
- adjustment = dot(training_set_inputs.T, error * self.__sigmoid_derivative(output))
- self.synaptic_weights += adjustment
- def predict(self, inputs):
- return self.__sigmoid(dot(inputs, self.synaptic_weights))
- if __name__=="__main__":
- #initialize a single neuron neural network
- neural_network = NeuralNetwork()
- # training data inputs / outputs
- training_set_inputs = array([t_in])
- training_set_outputs = array([y]).T
- # number of iterations
- neural_network.train(training_set_inputs, training_set_outputs, 10000)
- # new input to predict
- my_input = array([6,102,3000])
- print 'New synaptic weights after training'
- print neural_network.synaptic_weights
- print 'Predicting'
- my_prediction = neural_network.predict(my_input)
- print (my_prediction)
- # t_in = [[6.0, 102.0, 0.0], [61.0, 138.0, 12414.0], [224.0, 291.0, 30309.0]]
- #y = [[ 1.]
- [ 1.]
- [ 1.]
- ...,
- [ 0.]
- [ 0.]
- [ 0.]]
- adjustment = dot(training_set_inputs.T, error * self.__sigmoid_derivative(output)) ValueError: shapes (3,2736,1) and (1,2736,1) not aligned: 1 (dim 2) != 2736 (dim 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement