Exemple #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)
Exemple #2
0
 def __call__(self, input):
     return self.ToImg(last(self.Encode(input)))
Exemple #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))) 
Exemple #4
0
 def encode(self, inp):
     return last(self.Encode(inp))
Exemple #5
0
 def __call__(self, inp):
     return self.visual_activation(self.ToImg(last(self.Encode(inp))))
Exemple #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)
Exemple #7
0
 def __call__(self, input):
     return util.l2norm(last(self.Encode(input)))
Exemple #8
0
 def __call__(self, inp):
     return self.visual_activation(self.ToImg(last(self.Encode(inp))))
Exemple #9
0
 def __call__(self, input):
     return self.project(layer.last(self.encode(input)))
Exemple #10
0
def bidi_encode(layer, inp):
    """Return encoded input from a bidirectional encoder."""
    f,b = layer.bidi(inp)
    return last(f) + first(b)
Exemple #11
0
 def __call__(self, input):
     rep = last(self.Encode(input))
     return self.ToImg(rep)
Exemple #12
0
 def __call__(self, inp):
     return self.Project(last(self.Encode(inp)))
Exemple #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))))))
Exemple #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)
Exemple #15
0
 def __call__(self, input):
     return self.project(layer.last(self.encode(input)))
Exemple #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))))
Exemple #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)
Exemple #18
0
 def encode(self, inp):
     return last(self.Encode(inp))
Exemple #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))))
Exemple #20
0
 def __call__(self, input):
     return self.network.ToImg(last(self.network.EncodeV(self.network.Shared(input))))
Exemple #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])