(linear, x)
return torch.transpose(h.view(batch, length, hidden_size, 1), 1, 2)
linear transform for 3-d tensor
linear transform for 3-d tensor
linear transform for 3 - d tensor
def seq_linear(linear, x):
    """ linear transform for 3-d tensor """
    batch, hidden_size, length, _ = x.size()
    h = linear(torch.transpose(x, 1, 2).contiguous().view(
        batch * length, hidden_size))
    return torch.transpose(h.view(batch, length, hidden_size, 1), 1, 2)
def seq_linear ( linear , x ) : batch , hidden_size , length , _ = x . size ( ) h = linear ( torch . transpose ( x , 1 , 2 ) . contiguous ( ) . view ( batch * length , hidden_size ) ) return torch . transpose ( h . view ( batch , length , hidden_size , 1 ) , 1 , 2 )