It is as the error says, the weight attribute in the forward step should be a 2D tensor to take its transpose, but the weight size for your model is 1D.
In the second example the weight vector is indeed 2D and thus you can take its transpose.