Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

TypeError: Compose expect Symbol as arguments #5178

Description

@poorfriend

I want to implement CNN_BLSTM_CTC with CUDNN, but an error arise:
Traceback (most recent call last):
File "/home/Documents/MyCode/VLPR/view.py", line 25, in
output = CNN_MultiBLSTM_CTC_CUDNN(num_hidden, num_label, num_lstm_layer)
File "/home/Documents/MyCode/VLPR/blstm.py", line 325, in CNN_MultiBLSTM_CTC_CUDNN
output, _ = cell.unroll(num_length, inputs=hidden, merge_outputs=True, layout='NTC')
File "/home/mxnet/python/mxnet/rnn/rnn_cell.py", line 637, in unroll
inputs = symbol.Concat(inputs, dim=0)
File "/home/mxnet/python/mxnet/_ctypes/symbol.py", line 191, in creator
s._compose(*args, name=name, **symbol_kwargs)
File "/home/mxnet/python/mxnet/symbol.py", line 241, in _compose
raise TypeError('Compose expect Symbol as arguments')
TypeError: Compose expect Symbol as arguments

Here is my code, How can I fix it

`def CNN_MultiBLSTM_CTC_CUDNN(num_hidden, num_label, num_lstm_layer, num_class = 70, num_length = 32):

data = mx.sym.Variable('data')
label = mx.sym.Variable('label')

wordvec = CNN(data)
hidden = [mx.symbol.Flatten(wordvec[i]) for i in range(num_length)]

cell = mx.rnn.FusedRNNCell(num_hidden, num_layers=num_lstm_layer, mode='lstm', bidirectional=True)

output, _ = cell.unroll(num_length, inputs=hidden, merge_outputs=True, layout='NTC')

pred = mx.sym.Reshape(output, shape=(-1, num_hidden))

pred = mx.sym.FullyConnected(data=pred, num_hidden=num_class)

label = mx.sym.Reshape(data=label, shape=(-1,))
label = mx.sym.Cast(data=label, dtype='int32')
sm = mx.sym.WarpCTC(data=pred, label=label, label_length=num_label, input_length=num_length)

return sm`

def CNN3(indata):
"""the net is similar to VGG16
each image size is 64256
"""
# stage 1
body = CNN_Module(data=indata, kernel=(3, 3), pad=(1, 1), num_filter=64, stride=(1, 1), num_module=2, BatchNorm=True)
body = mx.symbol.Pooling(data=body, pool_type="max", kernel=(2, 2), stride=(2, 2)) #32
128
# stage 2
body = CNN_Module(data=body, kernel=(3, 3), pad=(1, 1), num_filter=128, stride=(1, 1), num_module=2, BatchNorm=True)
body = mx.symbol.Pooling(data=body, pool_type="max", kernel=(2, 2), stride=(2, 2)) #1664
# stage 3
body = CNN_Module(data=body, kernel=(3, 3), pad=(1, 1), num_filter=256, stride=(1, 1), num_module=2, BatchNorm=True)
body = mx.symbol.Pooling(data=body, pool_type="max", kernel=(2, 2), stride=(2, 2)) #8
32
# stage 4
body = CNN_Module(data=body, kernel=(3, 3), pad=(1, 1), num_filter=256, stride=(1, 1), num_module=2, BatchNorm=True)
body = mx.symbol.Pooling(data=body, pool_type="max", kernel=(2, 1), stride=(2, 1)) #432
# stage 5
body = CNN_Module(data=body, kernel=(3, 3), pad=(1, 1), num_filter=512, stride=(1, 1), num_module=2, BatchNorm=True)
body = mx.symbol.Pooling(data=body, pool_type="max", kernel=(2, 1), stride=(2, 1)) #2
32
# stage 5
body = CNN_Module(data=body, kernel=(2, 1), pad=(0, 0), num_filter=512, stride=(1, 1), num_module=1, BatchNorm=True)
body = mx.sym.SliceChannel(data=body, num_outputs=32, axis=3, squeeze_axis=1)

return body

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions