Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

PyTorch - Perceptron

Back


Perceptron


perceptron_diagram


pytorch-perceptron3



Example(待续)


import torch
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets

# define number of points
no_of_points = 100
# define clusters' centers
centers = [[-0.5, 0.5], [0.5, -0.5]]
# .make_blobs(): Generate isotropic Gaussian blobs for clustering.
x, y = datasets.make_blobs(
    n_samples=no_of_points,
    random_state=42,
    centers=centers,
    cluster_std=0.4
)

print(x)
print(y)
def Scatter():
    plt.scatter(x[y == 0, 0], x[y == 0, 1])
    plt.scatter(x[y == 1, 0], x[y == 1, 1])

Scatter()

TOP