microsoft / CNTK

Microsoft Cognitive Toolkit (CNTK), an open source deep-learning toolkit
https://docs.microsoft.com/cognitive-toolkit/
Other
17.52k stars 4.28k forks source link

Error on Keras Conv2DTranspose with CNTK backend #3462

Open arijit17 opened 6 years ago

arijit17 commented 6 years ago

Hi!

I'm using latest CNTK and Keras on Windows.

I'm faced with an error on Keras Conv2DTranspose as shown below. The code works fine with TensorFlow backend. Any idea what's going on?

File "F:\GIT\PythonKerasNeuralNetworkImplemention\CT\keras_CTsynth.py", line 70, in generate_model_syn
    model.add(Conv2DTranspose(filters=1, kernel_size=(filtlen,1), strides=(N,1), activation="linear", use_bias=False, kernel_initializer=CT_syn_init, input_shape=(None,1,N)))
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\keras\engine\sequential.py", line 165, in add
    layer(x)
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\keras\engine\base_layer.py", line 507, in __call__
    inputs=to_list(inputs))
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\keras\backend\cntk_backend.py", line 50, in name_scope
    yield
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\keras\engine\base_layer.py", line 457, in __call__
    output = self.call(inputs, **kwargs)
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\keras\layers\convolutional.py", line 853, in call
    dilation_rate=self.dilation_rate)
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\keras\backend\cntk_backend.py", line 2236, in conv2d_transpose
    dilation=dilation_rate)
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\cntk\internal\swig_helper.py", line 69, in wrapper
    result = f(*args, **kwds)
  File "C:\Users\abisw\AppData\Local\Continuum\Anaconda3\lib\site-packages\cntk\ops\__init__.py", line 423, in convolution_transpose
    output_shape, dilation, reduction_rank, max_temp_mem_size_in_samples, name)
NotImplementedError: Wrong number or type of arguments for overloaded function 'convolution_transpose'.
  Possible C/C++ prototypes are:
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< bool,std::allocator< bool > > const &,CNTK::NDShape const &,CNTK::NDShape const &,size_t,size_t,std::wstring const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< bool,std::allocator< bool > > const &,CNTK::NDShape const &,CNTK::NDShape const &,size_t,size_t)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< bool,std::allocator< bool > > const &,CNTK::NDShape const &,CNTK::NDShape const &,size_t)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< bool,std::allocator< bool > > const &,CNTK::NDShape const &,CNTK::NDShape const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< bool,std::allocator< bool > > const &,CNTK::NDShape const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< bool,std::allocator< bool > > const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< size_t,std::allocator< size_t > > const &,std::vector< size_t,std::allocator< size_t > > const &,CNTK::NDShape const &,CNTK::NDShape const &,size_t,std::wstring const &)
    CNTK::ConvolutionTranspose(CNTK::Variable const &,CNTK::Variable const &,CNTK::NDShape const &,std::vector< bool,std::allocator< bool > > const &,std::vector< size_t,std::allocator< size_t > > const &,std::vector< size_t,std::allocator< size_t > > const &,CNTK::NDShape const &,CNTK::NDShape const &,size_t)
delzac commented 6 years ago

What version of cntk are you using?

arijit17 commented 6 years ago

@delzac Latest and greatest CNTK 2.6 and Keras 2.2.4

arijit17 commented 6 years ago

@delzac are you also facing similar issues?

delzac commented 6 years ago

Hi, i did a quick debugging, i don't think you can use None in input_shape. I personally don't use Keras, so i'm not sure how they implement cntk in the backend.

I changed None to a int and it worked.

arijit17 commented 6 years ago

Hi @delzac : indeed replacing the None in input_shape=(None,1,N) solves. But this is not desired. So, as far as I see this is a bug!

delzac commented 6 years ago

What's your None for? To declare an undefined channel axis?