Perception import math import matplotlib.pyplot as plt import numpy as np 입력 : 입력: (x1, x2) 출력: a = x1 * w1 + x2 * w2 + b 계산 y = 1, a > 임계값= 0, a Example def step_function(x): if x > 0: return 1 else: return 0 > Execute x = np.arange(-3, 4) print('x = ', x) for x_i in x: print(step_function(x_i), end ='\t') > Result x = [-3 -2 -1 0 1 2 3] 0 0 0 0 1 1 1 > Numpy.exp()와 Math.exp() 비교 def step_funct..
Python
Perceptron(퍼셉트론) 다수의 신호를 입력 받아서, 하나의 신호를 출력 - And Gate def and_gate(x1, x2): w1, w2 = 1.0, 1.0 # 가중치 bias = -1 y = x1 * w1 + x2 * w2 + bias if y > 0: return 1 else: return 0 - Or Gate def or_gate(x1, x2): w1, w2 = 1.0, 1.0 b = -0.5 y = x1 * w1 + x2 * w2 + b if y > 0: return 1 else: return 0 - Nand Gate def nand_gate(x1, x2): w1, w2 = 0.5, 0.5 # 가중치(weight) b = 0 # 편향(bias) y = x1 * w1 + x2 * w2 ..
# numpy.c_ (column bind)와 numpy_r(row bind)의 비교a = np.array([1, 2, 3])b = np.array([4, 5, 6])print(a, type(a), a.shape)print(b, type(b), b.shape) [1 2 3] (3,)[4 5 6] (3,) c = np.c_[a, b]print(c, type(c), c.shape)[[1 4] [2 5] [3 6]] (3, 2) d = np.r_[a, b]print(d, type(d), d.shape)[1 2 3 4 5 6] (6,) e = np.r_[[a], [b]]print(e, type(e), e.shape)[[1 2 3] [4 5 6]] (2, 3) f = np.array([[1, 2, 3], [4, ..
import mathimport numpy as npfrom sklearn.datasets import load_irisimport matplotlib.pyplot as plt iris = load_iris()print(iris.keys())print(iris.DESCR) dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names', 'filename']) ...중요한 정보만 확인 :Attribute Information: - sepal length in cm - sepal width in cm - petal length in cm - petal width in cm - class: - Iris-Setosa - Iris-Versicolour..