Skip to content

Instantly share code, notes, and snippets.

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 aaronstjohn/0dd049abdfb8bceab724f8932202eb24 to your computer and use it in GitHub Desktop.
Save aaronstjohn/0dd049abdfb8bceab724f8932202eb24 to your computer and use it in GitHub Desktop.
def plot_decision_boundary_gpu(pred_func):
# Set min and max values and give it some padding
x_min, x_max = train_X[:, 0].min() - .5, train_X[:, 0].max() + .5
y_min, y_max = train_X[:, 1].min() - .5, train_X[:, 1].max() + .5
h = 0.01
# Generate a grid of points with distance h between them
xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
X.set_value((np.c_[xx.ravel(), yy.ravel()]).astype('float32'))
#Z = pred_func(np.c_[xx.ravel(), yy.ravel()])
Z = pred_func()
Z = Z.reshape(xx.shape)
# Plot the contour and training examples
plt.contourf(xx, yy, Z, cmap=plt.cm.Spectral)
plt.scatter(train_X[:, 0], train_X[:, 1], c=train_y, cmap=plt.cm.Spectral)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment