(self, hidden)
return outs
Forward hidden state through bridge
Forward hidden state through bridge
Forward hidden state through bridge
def _bridge(self, hidden):
        """
        Forward hidden state through bridge
        """
        def bottle_hidden(linear, states):
            """
            Transform from 3D to 2D, apply linear and return initial size
            """
            size = states.size()
            result = linear(states.view(-1, self.total_hidden_dim))
            return F.relu(result).view(size)

        if isinstance(hidden, tuple):  # LSTM
            outs = tuple([bottle_hidden(layer, hidden[ix])
                          for ix, layer in enumerate(self.bridge)])
        else:
            outs = bottle_hidden(self.bridge[0], hidden)
        return outs
def _bridge ( self , hidden ) : def bottle_hidden ( linear , states ) : """
            Transform from 3D to 2D, apply linear and return initial size
            """ size = states . size ( ) result = linear ( states . view ( - 1 , self . total_hidden_dim ) ) return F . relu ( result ) . view ( size ) if isinstance ( hidden , tuple ) : # LSTM outs = tuple ( [ bottle_hidden ( layer , hidden [ ix ] ) for ix , layer in enumerate ( self . bridge ) ] ) else : outs = bottle_hidden ( self . bridge [ 0 ] , hidden ) return outs