Skip to content

Instantly share code, notes, and snippets.

@Dpananos
Created October 27, 2020 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dpananos/8bed5adc42c81e4ed41b0749434199a6 to your computer and use it in GitHub Desktop.
Save Dpananos/8bed5adc42c81e4ed41b0749434199a6 to your computer and use it in GitHub Desktop.
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