This error has appeared on the forum many times, but it doesn’t seem to be the same as my question.
I’m trying to learn how to use the convolution transpose API,and this is my code:
I use the transpose convolution and its kernel size is (1,1),stride is (2,2). And I then customized the weights so that I could see the end result
Input=np.asarray([[1,2],[3,4]]) Input=Input.reshape((1,1,2,2)) Input=torch.from_numpy(Input).float() print(Input.shape) model=torch.nn.Sequential() transpose=torch.nn.ConvTranspose2d(1,1,kernel_size=1,stride=2) weight=np.asarray([[]]) bias=np.asarray() weight=torch.Tensor(weight) bias=torch.Tensor(bias) transpose.weight=torch.nn.Parameter(weight) transpose.bias=torch.nn.Parameter(bias) model.add_module('transpose',transpose) yhat=model(Input) yhat=yhat.reshape((4,4)) print(yhat)
And the error is: