Search code examples
deep-learningmxnet

mxnet failed to infer type


My mxnet code - which consists of a series of complex connections and slicing raises the following error:

Error in operator concat0: [03:03:51] src/operator/./concat-inl.h:211: Not enough information to infer type in Concat.

Im not sure how to interpret that or what information to provide to help debug it. Concat0 is part of the operation:

# Define take_column function as transpose(take(transpose(x), i))

for i in range(47):
    y_hat_lt = take_column(y_hat,
                mx.sym.concat(mx.sym.slice(some_indices, begin=i, end=i+1), self.label_dim + mx.sym.slice(some_indices, begin=i, end=i+1), dim=0))

here some_indices is a variable which I fix to be a list. Do let me know!


Solution

  • Instead of taking transpose, swapping among the axis resolved the issue.

    def ttake( x, i ):
        """ Take from axis 1 instead of 0.
        """
        a = mx.sym.swapaxes(x, dim1=0, dim2=1)
        return mx.sym.flatten( mx.sym.transpose( mx.sym.take( a , i ) ) )