Exemplo n.º 1
0
 def __call__(self, inp, output_prev, _img):
     shared = self.Shared(self.Embed(inp))
     img_pred = self.Visual(shared)
     txt_pred = softmax3d(
         self.Embed.unembed(
             self.ToTxt(self.LM(last(shared), self.Embed(output_prev)))))
     return (img_pred, txt_pred)
Exemplo n.º 2
0
 def __call__(self, input):
     return self.ToImg(last(self.Encode(input)))
Exemplo n.º 3
0
 def __call__(self, input):
     # Using last because Sum returns the whole seq of partial sums
     # to be compatible with recurrent layers.
     return util.l2norm(last(self.Encode(input))) 
Exemplo n.º 4
0
 def encode(self, inp):
     return last(self.Encode(inp))
Exemplo n.º 5
0
 def __call__(self, inp):
     return self.visual_activation(self.ToImg(last(self.Encode(inp))))
Exemplo n.º 6
0
 def __call__(self, inp, out_prev, _img):
     rep = last(self.Encode(self.Embed(inp)))
     img = self.visual_activation(self.DecodeV(rep))
     txt = softmax3d(self.Embed.unembed(self.PredictT(self.DecodeT(rep, self.Embed(out_prev)))))
     return (img, txt)
Exemplo n.º 7
0
 def __call__(self, input):
     return util.l2norm(last(self.Encode(input)))
Exemplo n.º 8
0
 def __call__(self, inp):
     return self.visual_activation(self.ToImg(last(self.Encode(inp))))
Exemplo n.º 9
0
 def __call__(self, input):
     return self.project(layer.last(self.encode(input)))
Exemplo n.º 10
0
def bidi_encode(layer, inp):
    """Return encoded input from a bidirectional encoder."""
    f,b = layer.bidi(inp)
    return last(f) + first(b)
Exemplo n.º 11
0
 def __call__(self, input):
     rep = last(self.Encode(input))
     return self.ToImg(rep)
Exemplo n.º 12
0
 def __call__(self, inp):
     return self.Project(last(self.Encode(inp)))
Exemplo n.º 13
0
 def predictor_v(self):
     """Return function to predict image vector from input."""
     input = T.imatrix()
     return theano.function([input], self.visual_activation(self.ToVis(last(self.Encode(self.Embed(input))))))
Exemplo n.º 14
0
 def __call__(self, inp, out_prev, img):
     img_out = self.visual_activation(self.ToVis(last(self.Encode(self.Embed(inp)))))
     txt_out = softmax3d(self.Embed.unembed(self.PredictT(self.Decode(self.visual_activation(self.FromVis(img)),
                                                                self.Embed(out_prev)))))
     return (img_out, txt_out)
Exemplo n.º 15
0
 def __call__(self, input):
     return self.project(layer.last(self.encode(input)))
Exemplo n.º 16
0
 def predictor_r(self):
     """Return function to predict representation from input."""
     input = T.imatrix()
     return theano.function([input], last(self.Shared(self.Embed(input))))
Exemplo n.º 17
0
 def __call__(self, inp, output_prev, _img):
     shared = self.Shared(self.Embed(inp))
     img_pred = self.Visual(shared)
     txt_pred = softmax3d(self.Embed.unembed(self.ToTxt(self.LM(last(shared), self.Embed(output_prev)))))
     return (img_pred, txt_pred)
Exemplo n.º 18
0
 def encode(self, inp):
     return last(self.Encode(inp))
Exemplo n.º 19
0
 def predictor_r(self):
     """Return function to predict representation from input."""
     input = T.imatrix()
     return theano.function([input], last(self.Shared(self.Embed(input))))
Exemplo n.º 20
0
 def __call__(self, input):
     return self.network.ToImg(last(self.network.EncodeV(self.network.Shared(input))))
Exemplo n.º 21
0
def make_predict_next(net): 
    out_prev = T.imatrix()
    rep_prev = T.fmatrix()
    rep = net.LM(rep_prev, net.Embed(out_prev))
    out = softmax3d(net.Embed.unembed(net.ToTxt(rep)))
    return theano.function([rep_prev, out_prev], [last(rep), out])