These are chat archives for dmlc/mxnet

Feb 2018
Sam Hodge
Feb 22 2018 02:37
Does anybody have experience with how to get the shape of a Symbol using infer_shape?
Anirudh Subramanian
Feb 22 2018 03:29
hi @samhodge sorry i have been busy and havent gotten a chance to look at your changes. Have you looked at infer_shape documentation ?
Anirudh Subramanian
Feb 22 2018 03:36
i think you should be able to use infer_shape without any arguments
the shape should be inferred when data is bound to the symbolic inputs to the model
Sam Hodge
Feb 22 2018 11:49
I will try again, I looked
Anirudh Subramanian
Feb 22 2018 17:15
its not very clear from the documentation. maybe we should add an example to the documentation.
Sam Hodge
Feb 22 2018 22:47
/home/samh/dev/MXNet-Gluon-Style-Transfer/ UserWarning: Cannot decide shape for the following arguments (0s in shape means unknown dimensions). Consider providing them as input:
data: ()
in_shapes,out_shapes,arg_shapes= X.infer_shape()
that is not a good start
With this
`class Inspiration(HybridBlock):
""" Inspiration Layer (from MSG-Net paper)
tuning the featuremap with target Gram Matrix
def init(self, C, B=1, ctx=mx.cpu(0)):
super(Inspiration, self).init()
    # B is equal to 1 or input mini_batch
    self.C = C
    self.B = B

    self.weight = self.collect_params().get('weight', shape=(1,self.C,self.C),
    self.gram = self.collect_params().get('gram', shape=(self.B,self.C,self.C),
def setTarget(self, target):
def hybrid_forward(self, F, X, gram, weight):

    P = F.batch_dot(F.broadcast_to(weight, shape=(self.gram.shape)), gram) 
    if not isinstance(X,symbol.Symbol):   
        return F.batch_dot(F.SwapAxis(P,1,2).broadcast_to((X.shape[0], self.C, self.C)), X.reshape((0,0,X.shape[2]*X.shape[3]))).reshape(X.shape)
        #print "Hooppla", interals
        #for i in dir(interals):
        #    print "kk:", i
        in_shapes,out_shapes,arg_shapes= X.infer_shape(self.gram.shape)
        #print out_shapes
        #raise Exception
        #arg_shapes, out_shapes, aux_shapes = interals.infer_shape(self.gram.shape)
        #print "A", arg_shapes, "O", out_shapes, "AU", aux_shapes
        return F.batch_dot(F.SwapAxis(P,1,2).broadcast_to((in_shapes[0], self.C, self.C)), X.reshape((0,0,in_shapes[2]*in_shapes[3]))).reshape(in_shapes)

def __repr__(self):
    return self.__class__.__name__ + '(' \
        + 'N x ' + str(self.C) + ')'`
i get the following error
Sam Hodge
Feb 22 2018 22:52
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid