Closed Harry040 closed 7 years ago
How did you manage to get this error? This can occur only if you choose to test the CRNN
model which is highly experimental and not recommended. CNN is better in pretty much every way.
Make sure to call this function with either "cnn"
or "rnn"
(but preferably cnn).
@jstypka I got it, this just works in tensorflow backend, thank you!
I also get this error today. I change the config file magpie/magpie/config.py
:
NN_ARCHITECHTURE = 'crnn'
Then when I run the training function, it will give the error:
File "/Users/bing/zhihu/ieee_zhihu_cup/magpie/magpie/nn/models.py", line 18, in get_nn_model
return crnn(embedding_size=embedding, output_length=output_length)
File "/Users/bing/zhihu/ieee_zhihu_cup/magpie/magpie/nn/models.py", line 63, in crnn
from keras.layers import AsymmetricZeroPadding1D
ImportError: cannot import name 'AsymmetricZeroPadding1D'
It seems that the keras.layers
module has no layer named "AsymmetricZeroPadding1D", I checked that my keras version is 1.2.2, which is installed according to the setup.py
. So I think maybe when Magpie's CRNN layer is first developed, there is a layer with that name(AsymmetricZeroPadding1D), but now it is changed into others, when I run dir(keras.layers)
in python3, I got those layer names:
['Activation', 'ActivityRegularization', 'AtrousConv1D', 'AtrousConv2D', 'AtrousConvolution1D',
'AtrousConvolution2D', 'AveragePooling1D', 'AveragePooling2D', 'AveragePooling3D',
'BatchNormalization', 'Bidirectional', 'Conv1D', 'Conv2D', 'Conv3D', 'ConvLSTM2D', 'ConvRecurrent2D',
'Convolution1D', 'Convolution2D', 'Convolution3D', 'Cropping1D', 'Cropping2D', 'Cropping3D',
'Deconv2D', 'Deconvolution2D', 'Dense', 'Dropout', 'ELU', 'Embedding', 'Flatten', 'GRU',
'GaussianDropout', 'GaussianNoise', 'GlobalAveragePooling1D', 'GlobalAveragePooling2D',
'GlobalAveragePooling3D', 'GlobalMaxPooling1D', 'GlobalMaxPooling2D', 'GlobalMaxPooling3D',
'Highway', 'Input', 'InputLayer', 'InputSpec', 'K', 'LSTM', 'Lambda', 'Layer', 'LeakyReLU',
'LocallyConnected1D', 'LocallyConnected2D', 'Masking', 'MaxPooling1D', 'MaxPooling2D',
'MaxPooling3D', 'MaxoutDense', 'Merge', 'PReLU', 'ParametricSoftplus', 'Permute', 'Recurrent',
'RepeatVector', 'Reshape', 'SReLU', 'SeparableConv2D', 'SeparableConvolution2D', 'SimpleRNN',
'SpatialDropout1D', 'SpatialDropout2D', 'SpatialDropout3D', 'ThresholdedReLU', 'TimeDistributed',
'TimeDistributedDense', 'UpSampling1D', 'UpSampling2D', 'UpSampling3D', 'Wrapper', 'ZeroPadding1D',
'ZeroPadding2D', 'ZeroPadding3D', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'absolute_import', 'activations', 'advanced_activations',
'constraints', 'conv_input_length', 'conv_output_length', 'convolutional', 'convolutional_recurrent', 'copy',
'core', 'division', 'embeddings', 'func_dump', 'func_load', 'functools', 'get_from_module', 'initializations',
'inspect', 'local', 'merge', 'noise', 'normalization', 'np', 'pooling', 'python_types', 'recurrent', 'regularizers',
'time_distributed_dense', 'warnings', 'wrappers']
It's almost impossible for me choose from so many names, so could you tell us what may be the equivalent one to "AsymmetricZeroPadding1D", or do I need to update or downgrade to other version of keras?
Thanks a lot!
hey @tarvos21 ! So the CRNN was kind of experimental and I had to write some custom code (the AsymmetricZeroPadding1D
layer) in order to get it running. There are a few more details about it here, but the bottom line is that you can't run this layer at the moment without writing custom additional code to Keras.
Nevertheless, it was not a very successful experiment - CRNN was in my experiments almost always worse than CNN, so for practical reasons you should probably use the CNN. I might remove the code for CRNN
from Magpie soon not to confuse anybody.
@jstypka, oh, I get it, great, thanks!
ImportError: cannot import name AsymmetricZeroPadding1D