Add missing BN layer in ResNet-34 and remove bias in Conv2D
parent
3313c21723
commit
f0b432eb59
|
@ -588,8 +588,8 @@
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"DefaultConv2D = partial(keras.layers.Conv2D,\n",
|
"DefaultConv2D = partial(keras.layers.Conv2D, kernel_size=3, strides=1,\n",
|
||||||
" kernel_size=3, strides=1, padding=\"SAME\")\n",
|
" padding=\"SAME\", use_bias=False)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class ResidualUnit(keras.layers.Layer):\n",
|
"class ResidualUnit(keras.layers.Layer):\n",
|
||||||
" def __init__(self, filters, strides=1, activation=\"relu\", **kwargs):\n",
|
" def __init__(self, filters, strides=1, activation=\"relu\", **kwargs):\n",
|
||||||
|
@ -626,6 +626,8 @@
|
||||||
"model = keras.models.Sequential()\n",
|
"model = keras.models.Sequential()\n",
|
||||||
"model.add(DefaultConv2D(64, kernel_size=7, strides=2,\n",
|
"model.add(DefaultConv2D(64, kernel_size=7, strides=2,\n",
|
||||||
" input_shape=[224, 224, 3]))\n",
|
" input_shape=[224, 224, 3]))\n",
|
||||||
|
"model.add(keras.layers.BatchNormalization())\n",
|
||||||
|
"model.add(keras.layers.Activation(\"relu\"))\n",
|
||||||
"model.add(keras.layers.MaxPool2D(pool_size=3, strides=2, padding=\"SAME\"))\n",
|
"model.add(keras.layers.MaxPool2D(pool_size=3, strides=2, padding=\"SAME\"))\n",
|
||||||
"prev_filters = 64\n",
|
"prev_filters = 64\n",
|
||||||
"for filters in [64] * 3 + [128] * 4 + [256] * 6 + [512] * 3:\n",
|
"for filters in [64] * 3 + [128] * 4 + [256] * 6 + [512] * 3:\n",
|
||||||
|
|
Loading…
Reference in New Issue