You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/08/17 14:28:35 UTC
[GitHub] timprepscius opened a new issue #12221: mxnet keras padding strides,
maybe not correct?
timprepscius opened a new issue #12221: mxnet keras padding strides, maybe not correct?
URL: https://github.com/apache/incubator-mxnet/issues/12221
```
import keras
from keras.models import Sequential, Model
from keras.layers import Dense, Dropout, Flatten, LSTM, ConvLSTM2D, Activation, Reshape, Input, Concatenate, concatenate
from keras.layers import Conv2D, MaxPooling2D, AveragePooling2D, ZeroPadding2D
from keras.layers.normalization import BatchNormalization
from keras import backend as K
i = Input(shape=(1, 256, 256))
c0 = Conv2D(7, kernel_size=3, activation="relu", padding="same", strides=1)
m0 = MaxPooling2D(pool_size=3, padding="same", strides=2)
c1 = Conv2D(7, kernel_size=7, activation="relu", padding="same", strides=2)
l = i
l = c0(l)
l = m0(l)
l = c1(l)
m = Model(inputs=[i], outputs=[l])
m.compile(
loss=keras.losses.mean_squared_error,
optimizer=keras.optimizers.Adadelta()
)
print(m.summary())
```
results in:
```
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 1, 256, 256) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 7, 256, 256) 70
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 7, 128, 128) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 7, 64, 64) 2408
=================================================================
Total params: 2,478
Trainable params: 2,478
Non-trainable params: 0
_________________________________________________________________
None
```
(The output sized changes when stride is not 1, even though padding was "same")
I think it should result in:
```
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
input_1 (InputLayer) (None, 1, 256, 256) 0
_________________________________________________________________
conv2d_1 (Conv2D) (None, 7, 256, 256) 70
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 7, 256, 256) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 7, 256, 256) 2408
=================================================================
Total params: 2,478
Trainable params: 2,478
Non-trainable params: 0
_________________________________________________________________
None
```
But I could be wrong of course.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services