project-bikesharing/my_answers.py
def backpropagation(self, final_outputs, hidden_outputs, X, y, delta_weights_i_h, delta_weights_h_o):
        ''' Implement backpropagation
         
            Arguments
            ---------
            final_outputs: output from forward pass
            y: target (i.e. label) batch
            delta_weights_i_h: change in weights from input to hidden layers
            delta_weights_h_o: change in weights from hidden to output layers

        '''
        #### Implement the backward pass here ####
        ### Backward pass ###

        error = y - final_outputs  # Output layer error is the difference between desired target and actual output.

        hidden_error = np.dot(self.weights_hidden_to_output, error)

        output_error_term = error

        hidden_error_term = hidden_error * hidden_outputs * (1 - hidden_outputs)

        # Weight step (input to hidden)
        delta_weights_i_h += np.dot(X.reshape(self.input_nodes, -1), hidden_error_term.reshape(-1, self.hidden_nodes))
        # Weight step (hidden to output)
        delta_weights_h_o += np.dot(hidden_outputs.reshape(self.hidden_nodes, -1),
                                    output_error_term.reshape(-1, self.output_nodes))

        return delta_weights_i_h, delta_weights_h_o
 Implement backpropagation
         
            Arguments
            ---------
            final_outputs: output from forward pass
            y: target (i.e. label) batch
            delta_weights_i_h: change in weights from input to hidden layers
            delta_weights_h_o: change in weights from hidden to output layers

        
Implement backpropagation
Arguments

output from forward pass
y: target  batch
delta_weights_i_h: change in weights from input to hidden layers
delta_weights_h_o: change in weights from hidden to output layers
Implement backpropagation Arguments output from forward pass y : target batch delta_weights_i_h : change in weights from input to hidden layers delta_weights_h_o : change in weights from hidden to output layers
def backpropagation(self, final_outputs, hidden_outputs, X, y, delta_weights_i_h, delta_weights_h_o):
        error = y - final_outputs  
        hidden_error = np.dot(self.weights_hidden_to_output, error)
        output_error_term = error
        hidden_error_term = hidden_error * hidden_outputs * (1 - hidden_outputs)
        delta_weights_i_h += np.dot(X.reshape(self.input_nodes, -1), hidden_error_term.reshape(-1, self.hidden_nodes))
        delta_weights_h_o += np.dot(hidden_outputs.reshape(self.hidden_nodes, -1),
                                    output_error_term.reshape(-1, self.output_nodes))
        return delta_weights_i_h, delta_weights_h_o
def backpropagation ( self , final_outputs , hidden_outputs , X , y , delta_weights_i_h , delta_weights_h_o ) : error = y - final_outputs hidden_error = np . dot ( self . weights_hidden_to_output , error ) output_error_term = error hidden_error_term = hidden_error * hidden_outputs * ( 1 - hidden_outputs ) delta_weights_i_h += np . dot ( X . reshape ( self . input_nodes , - 1 ) , hidden_error_term . reshape ( - 1 , self . hidden_nodes ) ) delta_weights_h_o += np . dot ( hidden_outputs . reshape ( self . hidden_nodes , - 1 ) , output_error_term . reshape ( - 1 , self . output_nodes ) ) return delta_weights_i_h , delta_weights_h_o
Implement backpropagation
Arguments
Implement backpropagation Arguments
''' Implement backpropagation
         
            Arguments
            ---------
            final_outputs: output from forward pass
            y: target (i.e. label) batch
            delta_weights_i_h: change in weights from input to hidden layers
            delta_weights_h_o: change in weights from hidden to output layers

        ''' #### Implement the backward pass here #### ### Backward pass ### # Output layer error is the difference between desired target and actual output. # Weight step (input to hidden) # Weight step (hidden to output)
self
final_outputs
hidden_outputs
X
y
delta_weights_i_h
delta_weights_h_o