Skip to content

Commit 6976b57

Browse files
committed
done with the Python part of model serialization tutorial
1 parent fabfeee commit 6976b57

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Diff for: load/state_dict.ipynb

+15-4
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"cell_type": "markdown",
141141
"metadata": {},
142142
"source": [
143-
"Remember, that initially all parameters are initialized with random values, e.g."
143+
"Remember, that after the model instantiation its parameters are initialized with random values, e.g."
144144
]
145145
},
146146
{
@@ -152,8 +152,8 @@
152152
"data": {
153153
"text/plain": [
154154
"Parameter containing:\n",
155-
"tensor([ 0.1578, 0.1650, -0.1272, -0.1976, 0.0318, -0.1246, -0.0474, -0.0620,\n",
156-
" 0.1829, -0.1198], requires_grad=True)"
155+
"tensor([-0.1677, 0.1930, -0.0675, 0.0393, -0.1062, -0.0804, 0.0219, 0.0191,\n",
156+
" 0.0188, -0.1543], requires_grad=True)"
157157
]
158158
},
159159
"execution_count": 4,
@@ -175,7 +175,9 @@
175175
{
176176
"cell_type": "code",
177177
"execution_count": 5,
178-
"metadata": {},
178+
"metadata": {
179+
"scrolled": true
180+
},
179181
"outputs": [
180182
{
181183
"data": {
@@ -196,6 +198,15 @@
196198
"model.conv1.bias"
197199
]
198200
},
201+
{
202+
"cell_type": "markdown",
203+
"metadata": {},
204+
"source": [
205+
"Now we can use our model for scoring.\n",
206+
"\n",
207+
"To continue training from the saved checkpoint, we also need to instantiate the optimizer and initialize it (using [`torch.optim.Optimizer.load_state_dict()`](https://pytorch.org/docs/stable/optim.html#torch.optim.Optimizer.load_state_dict)). This is required because many of the optimizer's parameters (learning rate, momentum, etc.) change in training, and we often want to resume training from a certain checkpoint."
208+
]
209+
},
199210
{
200211
"cell_type": "code",
201212
"execution_count": null,

0 commit comments

Comments
 (0)