Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Set the learning rate: learning_rate
- learning_rate = 0.01
- # Calculate the predictions: preds
- preds = (weights * input_data).sum()
- # Calculate the error: error
- error = preds - target
- # Calculate the slope: slope
- slope = 2 * input_data * error
- # Update the weights: weights_updated
- weights_updated = weights - (slope * learning_rate)
- # Get updated predictions: preds_updated
- preds_updated = (weights * input_data).sum()
- # Calculate updated error: error_updated
- error_updated = preds_updated - target
- # Print the original error
- print(error)
- # Print the updated error
- print(error_updated)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement