Created
October 27, 2020 19:23
-
-
Save Dpananos/8bed5adc42c81e4ed41b0749434199a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
x = np.random.normal(size = 10) | |
y = 2*x + 1 + np.random.normal(0, 0.3, size=x.size) | |
grid = np.linspace(-12, 20, 25) | |
b0, b1 = np.meshgrid(grid, grid) | |
Loss = 0 | |
for xi, yi in zip(x,y): | |
Loss += (yi - b0 - b1*xi)**2 | |
fig = plt.figure() | |
ax = fig.gca(projection='3d') | |
ax.plot_surface(b0, b1, Loss) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment