質問編集履歴

2

追記

2018/10/24 08:27

投稿

Kohei_KESE
Kohei_KESE

スコア41

test CHANGED
File without changes
test CHANGED
@@ -58,4 +58,24 @@
58
58
 
59
59
  open('models/mnist_model.json', 'w').write(json_string)
60
60
 
61
+
62
+
63
+ #実行
64
+
65
+ history_adam = model.fit(
66
+
67
+ x_train,
68
+
69
+ y_train,
70
+
71
+ batch_size = 32,
72
+
73
+ epochs = 20,
74
+
75
+ validation_split = 0.2,
76
+
77
+ # callbacks = [tsb]
78
+
79
+ callbacks = [model_checkpoint])
80
+
61
81
  ```

1

追記

2018/10/24 08:27

投稿

Kohei_KESE
Kohei_KESE

スコア41

test CHANGED
File without changes
test CHANGED
@@ -13,3 +13,49 @@
13
13
  ```
14
14
 
15
15
  .json形式で保存したモデルを上記のプログラムで読み込もうとしたのですが、2行目でNo such file or directoryとエラーが出て読み込めませんでした。試しに、jsonファイルをカレントディレクトリに置くと読みこめたのですが、原因が分かりません。どなたか教えて頂きたいです。
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+ 追記
24
+
25
+
26
+
27
+ ```Python
28
+
29
+ model.compile(
30
+
31
+ optimizer="adam",
32
+
33
+ loss = "mean_squared_error",
34
+
35
+ metrics = ["accuracy"])
36
+
37
+
38
+
39
+ #重みとモデルの保存
40
+
41
+ os.makedirs('models', exist_ok=True)
42
+
43
+ model_checkpoint = ModelCheckpoint(
44
+
45
+ filepath = os.path.join('models', 'model_{epoch:02d}_{val_loss:.2f}.h5'),
46
+
47
+ monitor = 'val_loss',
48
+
49
+ verbose = 1,
50
+
51
+ period = 1,
52
+
53
+ save_best_only = True)
54
+
55
+
56
+
57
+ json_string = model.to_json()
58
+
59
+ open('models/mnist_model.json', 'w').write(json_string)
60
+
61
+ ```