回答編集履歴

1

追記

2021/05/29 14:56

投稿

hayataka2049
hayataka2049

スコア30933

test CHANGED
@@ -1 +1,49 @@
1
1
  恒常関数の場合、何段重ねても線形写像しか作れないことになります。
2
+
3
+
4
+
5
+
6
+
7
+ ---
8
+
9
+
10
+
11
+ ```python
12
+
13
+ import numpy as np
14
+
15
+ import matplotlib.pyplot as plt
16
+
17
+ from sklearn.neural_network import MLPRegressor
18
+
19
+
20
+
21
+ X = np.linspace(0, 2*np.pi, num=100).reshape(-1, 1)
22
+
23
+ y = np.sin(X).ravel()
24
+
25
+
26
+
27
+ plt.plot(X.ravel(), y, label="true")
28
+
29
+ for hls in [(25, ), (50, ), (25, 25), (50, 50)]:
30
+
31
+ mlp = MLPRegressor(hidden_layer_sizes=hls, activation="relu",
32
+
33
+ max_iter=2000)
34
+
35
+ mlp.fit(X, y)
36
+
37
+ y_pred = mlp.predict(X)
38
+
39
+ plt.plot(X.ravel(), y_pred, label=f"pred hidden_layer_sizes:{hls}")
40
+
41
+ plt.legend()
42
+
43
+ plt.show()
44
+
45
+ ```
46
+
47
+
48
+
49
+ ![イメージ説明](2349f8c0a61414b249030e8529e3e575.png)