Skip to content

Commit 01edb81

Browse files
authored
save the last checkpoint in the paligemma colab (#105)
1 parent 70b22bb commit 01edb81

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

big_vision/configs/proj/paligemma/finetune_paligemma.ipynb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,14 +1121,31 @@
11211121
"display(HTML(html_out))\n"
11221122
]
11231123
},
1124+
{
1125+
"cell_type": "markdown",
1126+
"metadata": {
1127+
"id": "Ai0NMbAwsr0j"
1128+
},
1129+
"source": [
1130+
"# Save the final checkpoint"
1131+
]
1132+
},
11241133
{
11251134
"cell_type": "code",
1126-
"source": [],
1135+
"execution_count": null,
11271136
"metadata": {
11281137
"id": "5H_3CV33_JkV"
11291138
},
1130-
"execution_count": null,
1131-
"outputs": []
1139+
"outputs": [],
1140+
"source": [
1141+
"def npsave(pytree, path):\n",
1142+
" names_and_vals, _ = big_vision.utils.tree_flatten_with_names(pytree)\n",
1143+
" with open(path, \"wb\") as f:\n",
1144+
" np.savez(f, **{k:v for k, v in names_and_vals})\n",
1145+
"\n",
1146+
"# Takes around 4 minutes\n",
1147+
"npsave(params, 'my-custom-paligemma-ckpt.npz')"
1148+
]
11321149
}
11331150
],
11341151
"metadata": {

0 commit comments

Comments
 (0)