model.py
def sample(self, inputs, states=None, max_len=20):
        " accepts pre-processed image tensor (inputs) and returns predicted sentence (list of tensor ids of length max_len) "
        res = []
        for i in range(max_len):
            outputs, states = self.lstm(inputs, states)
            outputs = self.linear(outputs.squeeze(1))
            _, predicted = outputs.max(1)
            res.append(predicted.item())
            inputs = self.embed(predicted)
            inputs = inputs.unsqueeze(1)
        return res
 accepts pre-processed image tensor (inputs) and returns predicted sentence (list of tensor ids of length max_len) 
accepts pre-processed image tensor (inputs) and returns predicted sentence (list of tensor ids of length max_len)
accepts pre - processed image tensor ( inputs ) and returns predicted sentence ( list of tensor ids of length max_len )
def sample(self, inputs, states=None, max_len=20):
        res = []
        for i in range(max_len):
            outputs, states = self.lstm(inputs, states)
            outputs = self.linear(outputs.squeeze(1))
            _, predicted = outputs.max(1)
            res.append(predicted.item())
            inputs = self.embed(predicted)
            inputs = inputs.unsqueeze(1)
        return res
def sample ( self , inputs , states = None , max_len = 20 ) : res = [ ] for i in range ( max_len ) : outputs , states = self . lstm ( inputs , states ) outputs = self . linear ( outputs . squeeze ( 1 ) ) _ , predicted = outputs . max ( 1 ) res . append ( predicted . item ( ) ) inputs = self . embed ( predicted ) inputs = inputs . unsqueeze ( 1 ) return res
accepts pre-processed image tensor (inputs) and returns predicted sentence (list of tensor ids of length max_len)
accepts pre - processed image tensor ( inputs ) and returns predicted sentence ( list of tensor ids of length max_len )
" accepts pre-processed image tensor (inputs) and returns predicted sentence (list of tensor ids of length max_len) "
self
inputs
states
max_len