{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import torch\n", "\n", "\n", "model_path = \"reuse_model.pth\"\n", "state_dict = torch.load(model_path)[\"state_dict\"]\n", "# Get the linear layer weights\n", "linear = {\n", " \"weight\": state_dict[\"head.weight\"].to(torch.float16),\n", " \"bias\": state_dict[\"head.bias\"].to(torch.float16)\n", "}\n", "# Save the linear layer weights\n", "torch.save(linear, \"files/reuse_linear.pth\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import torch\n", "\n", "\n", "model_path = \"price_model.pth\"\n", "state_dict = torch.load(model_path)[\"state_dict\"]\n", "# Get the linear layer weights\n", "linear = {\n", " \"weight\": state_dict[\"head.weight\"].to(torch.float16),\n", " \"bias\": state_dict[\"head.bias\"].to(torch.float16)\n", "}\n", "# Save the linear layer weights\n", "torch.save(linear, \"files/price_linear.pth\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }