if i have one Sequential, i know use torch.save(cnn.Conv1).
But if i have two Sequential or more , how can i save the network?
torch.save({'state_dict': model.state_dict()},
OUTPUT_FILENAME)
if i save the entire network, how can i do? i want to know this ,thank you
the code of above does what you ask for.
model.state_dict()
Is this not for saving parameters?
yes, it is. do you mean to store the network architecture def. as well?
yeah i want to save the entire network.
self.conv1 = nn.Sequential(
nn.Conv2d(
in_channels=3,
out_channels=32,
kernel_size=5,
stride=1,
padding=2,
), # 32, 32, 32
nn.ReLU(),
nn.MaxPool2d(2)
outshape(32, 16, 16)
)
# input shape (32, 16, 16)
self.conv2 = nn.Sequential(
nn.Conv2d(
in_channels=32,
out_channels=64,
kernel_size=5,
stride=1,
padding=2,
), # output shape (64, 16, 16)
nn.ReLU(),
nn.AvgPool2d(2), # (64, 8, 8)
)
i konw if i have one Sequential, i can use torch.save(net.conv1).
But if i have two and more Sequentials, how can i save the entire network?
How do you preserve this situation?
if i want save model neurel the best, ow can i do? i want to know this ,thank you