Error In This Simple Code

I wanted to try out some simple ops in pytorch and wrote the following in a jupyter notebook:

conv = nn.Conv2d(in_channels=1, out_channels=4, kernel_size=4)

x = np.random.randn(1, 1, 32, 32)
x = torch.tensor(x)

output = conv(x)

Yet somehow this simple piece of code throws an error.
Expected object of type torch.DoubleTensor but found type torch.FloatTensor for argument #2 'weight'

Why is this happening and more importantly, should this be happening?

Numpy uses np.float64 by default. Try to specify the dtype as np.float32 while creating x.
Alternatively, cast your tensor to float.