CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

CNTK can run the `MaxPooling2D` with unreasonable parameter `pool_size=0`

Open shiningrain opened this issue 5 years ago • 0 comments

System information

Have I written custom code (as opposed to using example directory): OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 &&Linux Ubuntu 18.04 CNTK backend (yes/no): yes CNTK version: 2.7(CPU) Python version: 3.6.9 CUDA/cuDNN version: - GPU model and memory: -

Describe the current behavior

When I use MaxPooling2D(pool_size=0) which is an obvious corner case, CNTK can run normally and even save the model. MaxPooling2D operation should not work with pool_size=0. It seems that a detection mechanism is missing in CNTK , which may confuse CNTK users.

Does pool_size=0 have some special meaning in CNTK? I have not found any description about this case in documents. If no special meaning, should CNTK set a check for such unreasonable parameters to avoid the risks and incorrect usages in the model?

Code to reproduce the issue

import os
import numpy as np
import keras.layers as L
from keras.engine import Model, Input

## Using CNTK as Keras backend.
## Input dtype default is float32

kwargs={'pool_size': (0, 0), 
        'padding': 'valid',
        'strides': (2, 1),
        'data_format': 'channels_last'}
input= (10 * np.random.random((1,32,32,16)))
layer = L.pooling.MaxPooling2D(**kwargs)
x = Input(batch_shape=input.shape)
y = layer(x)
bk_model = Model(x, y)
model_path = os.path.join('./', 'model.h5')
bk_model.save(model_path, bk_model)
print('finish')

shiningrain avatar Mar 05 '20 06:03 shiningrain