First, you need to resize all your inputs to a fixed size, then flatten your inputs. Flatten input size and first linear layer’s input sizes must match. Here is a sample code. Also as I recommend you to read docs as @ptrmcl suggested.
Also here is a sample for you. You can read what view do from docs. It is a simple function
>>> import torch
>>> input_tensor = torch.rand((1, 3, 224, 224)) # Input images resized to 224x224 in transform
>>> _, c, h, w = input_tensor.shape
>>> input_size_of_first_linear_layer = c * h * w
>>> flat_input_tensor = input_tensor.view(-1, input_size_of_first_linear_layer)
>>> input_tensor.shape
torch.Size([1, 3, 224, 224])
>>> flat_input_tensor.shape
torch.Size([1, 150528])
>>> layers = torch.nn.Sequential(
...     torch.nn.Linear(input_size_of_first_linear_layer, 1000),
...     torch.nn.Linear(1000, 2))
>>>
>>> layers
Sequential(
  (0): Linear(in_features=150528, out_features=1000, bias=True)
  (1): Linear(in_features=1000, out_features=2, bias=True)
)
>>> layers(flat_input_tensor)
tensor([[-0.0779,  0.3057]], grad_fn=<AddmmBac