質問編集履歴

2

コメント追記。

2019/09/01 09:54

投稿

open_your_eyes
open_your_eyes

スコア4

test CHANGED
File without changes
test CHANGED
@@ -13,6 +13,10 @@
13
13
  (少数点4桁くらい表示していますが、まったく変化せず)。
14
14
 
15
15
  計算グラフがうまくできておらず、誤差逆伝播ができていないのかと推察しています。
16
+
17
+
18
+
19
+ 以下、インデントが上手くされておらず、読みにくいコードになっておりすみません。
16
20
 
17
21
 
18
22
 

1

#つきのコメントを削除

2019/09/01 09:54

投稿

open_your_eyes
open_your_eyes

スコア4

test CHANGED
File without changes
test CHANGED
@@ -16,17 +16,11 @@
16
16
 
17
17
 
18
18
 
19
- # ResNet
20
-
21
- def _shortcut(inputs, residual): #inputs: ResBlockへの入力そのもの(ショートカットしたデータ), residual: ResBlockの中で処理されたデータ
22
-
23
- # residualのチャンネル数を取得
19
+ def _shortcut(inputs, residual)
24
20
 
25
21
  n_filters = residual.shape[3]
26
22
 
27
23
  print('n_filters=',n_filters)
28
-
29
- # inputsのチャンネル数をresidualのチャンネル数に合わせる(1x1畳み込み)
30
24
 
31
25
  shortcut = tf.layers.Conv2D(n_filters, kernel_size=[1, 1], strides=[1, 1], padding='VALID')(inputs)
32
26
 
@@ -58,8 +52,6 @@
58
52
 
59
53
 
60
54
 
61
- ### ネットワーク ###
62
-
63
55
  tf.reset_default_graph()
64
56
 
65
57
  is_training = tf.placeholder(tf.bool, shape=())
@@ -72,49 +64,51 @@
72
64
 
73
65
 
74
66
 
75
- ### ネットワーク本体 ###
76
-
77
67
  h = tf.layers.Conv2D(filters=32, kernel_size=[7, 7], strides=[1, 1], kernel_initializer=initializer, padding='SAME')(x)
78
68
 
79
69
  h = tf.layers.BatchNormalization()(h, training=is_training)
80
70
 
81
71
  h = tf.nn.relu(h)
82
72
 
83
- h = tf.layers.MaxPooling2D(pool_size=[2, 2], strides=2)(h) # 32x32x32 -> 16x16x32
73
+ h = tf.layers.MaxPooling2D(pool_size=[2, 2], strides=2)(h)
84
74
 
85
75
 
86
-
87
- h = _resblock(n_filters=64)(h) # 16x16x32 -> 16x16x64
88
76
 
89
77
  h = _resblock(n_filters=64)(h)
90
78
 
91
79
  h = _resblock(n_filters=64)(h)
92
80
 
93
- h = tf.layers.MaxPooling2D(pool_size=[2, 2], strides=2)(h) # 16x16x64 -> 8x8x64
81
+ h = _resblock(n_filters=64)(h)
94
82
 
95
- h = _resblock(n_filters=128)(h) # 8x8x64 -> 8x8x128
83
+ h = tf.layers.MaxPooling2D(pool_size=[2, 2], strides=2)(h)
84
+
85
+
96
86
 
97
87
  h = _resblock(n_filters=128)(h)
98
88
 
99
89
  h = _resblock(n_filters=128)(h)
100
90
 
101
- h = tf.layers.MaxPooling2D(pool_size=[2, 2], strides=2)(h) # 8x8x128 -> 4x4x128
91
+ h = _resblock(n_filters=128)(h)
102
92
 
93
+ h = tf.layers.MaxPooling2D(pool_size=[2, 2], strides=2)(h)
94
+
95
+
96
+
103
- h = _resblock(n_filters=256)(h) # 4x4x128 -> 4x4x256
97
+ h = _resblock(n_filters=256)(h)
104
98
 
105
99
  h = _resblock(n_filters=256)(h)
106
100
 
107
101
  h = _resblock(n_filters=256)(h)
108
102
 
109
- # Global Average Pooling
110
103
 
111
- h = tf.keras.layers.GlobalAveragePooling2D()(h) # 4x4x256 -> 256
112
104
 
113
- # FCN(全結合ネットワーク)
105
+ h = tf.keras.layers.GlobalAveragePooling2D()(h)
106
+
107
+
114
108
 
115
109
  h = tf.layers.Dense(units=128, activation=tf.nn.relu)(h)
116
110
 
117
- y = tf.layers.Dense(units=10, activation=tf.nn.softmax)(h) #各クラスのスコア
111
+ y = tf.layers.Dense(units=10, activation=tf.nn.softmax)(h)
118
112
 
119
113
 
120
114
 
@@ -126,9 +120,7 @@
126
120
 
127
121
  with tf.control_dependencies(update_ops):
128
122
 
129
- # optimizer = tf.train.AdamOptimizer(0.01).minimize(cost)
123
+ optimizer = tf.train.AdamOptimizer(0.01).minimize(cost)
130
-
131
- optimizer = tf.train.GradientDecentOptimizer(0.01).minimize(cost)
132
124
 
133
125
 
134
126