[Python] 14. NN : XOR문제, MLPClassifier
import numpy as np import pandas as pd import seaborn as sb import matplotlib.pyplot as plt import mglearn from sklearn.model_selection import train_test_split from sklearn.neural_network import MLPClassifier from sklearn.linear_model import LogisticRegression import warnings warnings.simplefilter('ignore') x_data = np.array( [[0,0],[0,1],[1,0],[1,1]]) y_data = np.array( [[0],[1],[1],[0]]) Logis..
[Python] 8. Sigmoid & Logistic
import numpy as np import pandas as pd import matplotlib.pyplot as plt import math x = np.array( [1., 2., 3., 4., 5., 6.] ) y = np.array( [ 5., 7., 9., 11., 13., 15.] ) w = 0 b = 0 n = len(x) epochs = 5000 learning_rate = 0.01 for i in range(epochs): hy = w*x + b # w=2, b=3 cost = np.sum((hy-y)**2)/n gradientW = np.sum(2*x*(w*x+b-y))/n gradientB = np.sum(2*1*(w*x+b-y))/n w=w-learning_rate*gradie..