- Join over
**1.5M+ people** - Join over
**100K+ communities** - Free
**without limits** - Create
**your own community**

the shape should be inferred when data is bound to the symbolic inputs to the model

that is not a good start

With this

`class Inspiration(HybridBlock):

""" Inspiration Layer (from MSG-Net paper)

tuning the featuremap with target Gram Matrix

ref https://arxiv.org/abs/1703.06953

"""

def**init**(self, C, B=1, ctx=mx.cpu(0)):

super(Inspiration, self).**init**()

""" Inspiration Layer (from MSG-Net paper)

tuning the featuremap with target Gram Matrix

ref https://arxiv.org/abs/1703.06953

"""

def

super(Inspiration, self).

```
# 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),
init=mx.initializer.Uniform(),
allow_deferred_init=True)
self.gram = self.collect_params().get('gram', shape=(self.B,self.C,self.C),
init=mx.initializer.Uniform(),
allow_deferred_init=True,
lr_mult=0)
self.weight.initialize(ctx=ctx)
self.gram.initialize(ctx=ctx)
def setTarget(self, target):
self.gram.set_data(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)
else:
#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

thanks for taking time out to work on this !

out_shape is an empty tuple in a list

how can I use that?

In C++

you are able to hybridize your model correct ?

but the model needs to know the resolution of the input data

before you can serialise it

let me show you what I mean

this commit kind of spells it out: samhodge/incubator-mxnet@1d72d60

I need to save parts of the model and put the pieces together in C++

https://mxnet.incubator.apache.org/api/python/symbol.html#mxnet.symbol.reshape yeah maybe it is not an issue

I can just reshape the appropriate symbole

it feels like I am trying to rough out an idea at this stage

https://github.com/samhodge/incubator-mxnet/blob/master/cpp-package/include/mxnet-cpp/symbol.hpp this has most of what I need

Actually dont worry about that, I think I need to continue on with a fixed resolution model first and simply try that out with the feedforward in C++ and then build it up from there, I am a little confused about if it is possible to build the gram matrix and the inspiration network in C++, but as a start it might be worth just loading up the model and params that I have for a decent trained model.