1
import numpy as np
np.random.seed(0)
a = np.random.randint(1,100, size= 1000).reshape(1000,1)
b = np.random.randint(0,2, size=1000).reshape(1000,1)
y = np.where(b==0,a*2, a*3)
X = np.hstack((a,b))
y = y
from sklearn.preprocessing import StandardScaler
sx = StandardScaler()
X = sx.fit_transform(X)
sy = StandardScaler()
y = sy.fit_transform(y)
w0 = np.random.normal(size=(2,1), scale=0.1)
for i in range(100):
input_layer = X
output_layer = X.dot(w0)
error = y - output_layer
square_error = np.sqrt(np.mean(error**2))
print(square_error)
w0+= input_layer.T.dot(error)
如果我理解正確,線性激活函數總是f(x)= x。我的線性迴歸神經網絡有什麼問題
如果你檢查這段代碼,你會發現正方形誤差正在增長並且在增長,我不知道如何用NN解決這個簡單的線性問題。我知道還有其他的模型和圖書館,但我試圖這樣做。
嘿米里亞姆,再次,非常感謝你。你是最棒的! – Makaroniiii
謝謝,很高興幫助:) –