回答編集履歴
3
fix cnn
test
CHANGED
@@ -205,27 +205,21 @@
|
|
205
205
|
]
|
206
206
|
|
207
207
|
def cnn(x):
|
208
|
+
x = Conv2D(64, 5, **kwargs)(x)
|
209
|
+
x = BatchNormalization()(x)
|
210
|
+
x = Activation("swish")(x)
|
211
|
+
x = DepthwiseConv2D(4, 2, **kwargs)(x)
|
212
|
+
x = BatchNormalization()(x)
|
213
|
+
x = Activation("swish")(x)
|
208
|
-
for layer in cnn_layers:
|
214
|
+
for layer in cnn_layers:
|
209
|
-
x = layer(x)
|
215
|
+
x = layer(x)
|
210
|
-
return x
|
216
|
+
return x
|
211
|
-
|
217
|
+
|
212
|
-
inputA = Input(shape = (512, 512, 1), name = "input_a")
|
218
|
+
inputA = Input(shape = (512, 512, 1), name = "input_a")
|
213
|
-
x = Conv2D(64, 5, **kwargs)(inputA)
|
214
|
-
x = BatchNormalization()(x)
|
215
|
-
x = Activation("swish")(x)
|
216
|
-
x = DepthwiseConv2D(4, 2, **kwargs)(x)
|
217
|
-
x = BatchNormalization()(x)
|
218
|
-
x = Activation("swish")(x)
|
219
|
-
x = cnn(
|
219
|
+
x = cnn(inputA)
|
220
|
-
|
220
|
+
|
221
|
-
inputB = Input(shape = (512, 512, 1), name = "input_b")
|
221
|
+
inputB = Input(shape = (512, 512, 1), name = "input_b")
|
222
|
-
y = Conv2D(64, 5, **kwargs)(inputB)
|
223
|
-
y = BatchNormalization()(y)
|
224
|
-
y = Activation("swish")(y)
|
225
|
-
y = DepthwiseConv2D(4, 2, **kwargs)(y)
|
226
|
-
y = BatchNormalization()(y)
|
227
|
-
y = Activation("swish")(y)
|
228
|
-
y = cnn(
|
222
|
+
y = cnn(inputB)
|
229
223
|
|
230
224
|
z = Concatenate(axis = -1)([x, y])
|
231
225
|
z = Dropout(0.25)(z)
|
2
fix answer
test
CHANGED
@@ -150,7 +150,7 @@
|
|
150
150
|
これでパラメータ数が`55,338,485`まで更に54%削減できました.当初のモデルと比較して95%もの削減になっています.
|
151
151
|
|
152
152
|
## 削減案4
|
153
|
-
流行を取り入れて次のようにします.`Dense`が5段あるのは多い気がしますが`Dropout`で過学習をカバーします.
|
153
|
+
`inputA`と`inputB`に大きな特徴の差異があっても良いように,序盤の畳み込みは各個別で行った上で流行を取り入れて次のようにします.`Dense`が5段あるのは多い気がしますが`Dropout`で過学習をカバーします.
|
154
154
|
|
155
155
|
```Python
|
156
156
|
from tensorflow.keras.layers import Input, Dense, Flatten, Concatenate, Activation
|
1
fix dense initializer
test
CHANGED
@@ -201,7 +201,7 @@
|
|
201
201
|
BatchNormalization(),
|
202
202
|
Activation("swish"),
|
203
203
|
GlobalAveragePooling2D(),
|
204
|
-
Dense(1024, activation = "swish"),
|
204
|
+
Dense(1024, activation = "swish", kernel_initializer = "he_uniform"),
|
205
205
|
]
|
206
206
|
|
207
207
|
def cnn(x):
|
@@ -229,11 +229,11 @@
|
|
229
229
|
|
230
230
|
z = Concatenate(axis = -1)([x, y])
|
231
231
|
z = Dropout(0.25)(z)
|
232
|
-
z = Dense(2048, activation = "swish")(z)
|
232
|
+
z = Dense(2048, activation = "swish", kernel_initializer = "he_uniform")(z)
|
233
233
|
z = Dropout(0.25)(z)
|
234
|
-
z = Dense(1024, activation = "swish")(z)
|
234
|
+
z = Dense(1024, activation = "swish", kernel_initializer = "he_uniform")(z)
|
235
235
|
z = Dropout(0.25)(z)
|
236
|
-
z = Dense(256, activation = "swish")(z)
|
236
|
+
z = Dense(256, activation = "swish", kernel_initializer = "he_uniform")(z)
|
237
237
|
output = Dense(class_num, activation = "softmax", name = "output")(z)
|
238
238
|
|
239
239
|
model = Model([inputA, inputB], output)
|