Commit 5ae15a79 authored by Mira Arabi Haddad's avatar Mira Arabi Haddad
Browse files

GROUPWORK_added plots

parent 9be2ebde
# External
import torch
import math
import matplotlib.pyplot as plt
def generate_disc_set(nb):
input = torch.empty(nb, 2).uniform_(0, 1)
# y^2 = r^2 - x^2
target = input.add(-0.5).pow(2).sum(1).sub(1/(2*math.pi)).sign().add(-3).div(2).long()
return input, ~target
# we will use this for both, at the beginning, and then to visually show the results for the test data
def plot_figure(input, output, center=(0.5,0.5), radius=1/math.sqrt(2*math.pi)):
plt.scatter(input[:,0], input[:,1], c=output, cmap='RdYlGn')
circle = plt.Circle(center, radius, color='black', fill=False, lw=5)
plt.gca().set_aspect('equal', adjustable='box')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment