質問編集履歴

2

全体コードを追加しました

2020/09/02 20:59

投稿

ponponn
ponponn

スコア2

test CHANGED
File without changes
test CHANGED
@@ -40,6 +40,90 @@
40
40
 
41
41
 
42
42
 
43
+ ### コード全体
44
+
45
+ ```
46
+
47
+ import tensorflow as tf
48
+
49
+ import datetime
50
+
51
+ import numpy as np
52
+
53
+ mnist = tf.keras.datasets.mnist
54
+
55
+
56
+
57
+ (x_train, y_train),(x_test, y_test) = mnist.load_data()
58
+
59
+ x_train, x_test = x_train / 255.0, x_test / 255.0
60
+
61
+
62
+
63
+ model = tf.keras.models.Sequential([
64
+
65
+ tf.keras.layers.Flatten(input_shape=(28, 28)),
66
+
67
+ tf.keras.layers.Dense(512, activation=tf.nn.relu),
68
+
69
+ tf.keras.layers.Dropout(0.2),
70
+
71
+ tf.keras.layers.Dense(10, activation=tf.nn.softmax)
72
+
73
+ ])
74
+
75
+ model.compile(optimizer='adam',
76
+
77
+ loss='sparse_categorical_crossentropy',
78
+
79
+ metrics=['accuracy'])
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+ log_dir="logs/fit/" + datetime.datetime.now().strftime("%Y%m%d-%H%M")
88
+
89
+ tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)
90
+
91
+
92
+
93
+
94
+
95
+ model.fit(x=x_train,
96
+
97
+ y=y_train,
98
+
99
+ epochs=5,
100
+
101
+ validation_data=(x_test, y_test),
102
+
103
+ callbacks=[tensorboard_callback])
104
+
105
+
106
+
107
+
108
+
109
+ file_writer = tf.summary.create_file_writer(log_dir)
110
+
111
+ with file_writer.as_default():
112
+
113
+ images = np.reshape(x_train[0:10], (-1, 28, 28, 1))
114
+
115
+ tf.summary.image("25 training data examples", images, max_outputs=10, step=epoch)
116
+
117
+
118
+
119
+
120
+
121
+ model.evaluate(x_test, y_test)
122
+
123
+ ```
124
+
125
+
126
+
43
127
  ### 環境
44
128
 
45
129
  Anaconda3

1

文の修正

2020/09/02 20:58

投稿

ponponn
ponponn

スコア2

test CHANGED
File without changes
test CHANGED
@@ -28,9 +28,15 @@
28
28
 
29
29
  と出ます。
30
30
 
31
- ![![このようにしたい](8bc16c634014ca52a41ab8cc1e54b532.jpeg)](479330c82417ff546b0849de47edd1e2.jpeg)
32
31
 
33
32
 
33
+ ↓のようにしたいです。
34
+
35
+ ![](8bc16c634014ca52a41ab8cc1e54b532.jpeg)](479330c82417ff546b0849de47edd1e2.jpeg)
36
+
37
+
38
+
39
+ 変更点などよろしくお願いします。
34
40
 
35
41
 
36
42