Variable(torch.Tensor(BB)). You can replace torch.Tensor with the type of desired precision, e.g. torch.DoubleTensor, torch.HalfTensor. If you run on GPU , remember to add .cuda() to either the Tensor or the Variable.