恒常関数の場合、何段重ねても線形写像しか作れないことになります。
python
1import numpy as np
2import matplotlib.pyplot as plt
3from sklearn.neural_network import MLPRegressor
4
5X = np.linspace(0, 2*np.pi, num=100).reshape(-1, 1)
6y = np.sin(X).ravel()
7
8plt.plot(X.ravel(), y, label="true")
9for hls in [(25, ), (50, ), (25, 25), (50, 50)]:
10 mlp = MLPRegressor(hidden_layer_sizes=hls, activation="relu",
11 max_iter=2000)
12 mlp.fit(X, y)
13 y_pred = mlp.predict(X)
14 plt.plot(X.ravel(), y_pred, label=f"pred hidden_layer_sizes:{hls}")
15plt.legend()
16plt.show()

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/05/29 11:11
2021/05/29 14:57
2021/05/29 18:05