I have a model which I train based on the torch in GPU. Now, i want to upload it on cpu. I am using this code to save an load the model.
Here is my model and the training phase:
model = VAE(input_size , lead, hidden_dim,hidden_dim1,hidden_dimd, latent_dim, device, num_hidden= lead).to(device)
optimizer = torch.optim.Adam(model.parameters(), lr =learning_rate )
losses, kl_loss, l_loss, validate_loss = trainv(model, device, epochs, train_iterator, optimizer, validate_iterator)
model = VAE()
torch.save(model.state_dict(), "model.pt")
#load
device = torch.device('cpu')
model = VAE()
model.load_state_dict(torch.load(PATH, map_location=device))
Here is the error:
TypeError: __init__() missing 8 required positional arguments: