update train file nam

This commit is contained in:
Victor Phan
2026-03-03 20:36:24 +07:00
parent 0a892c736a
commit 7574cec64d
14 changed files with 26 additions and 75 deletions
-49
View File
@@ -428,55 +428,6 @@
"plt.tight_layout()\n",
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "28f87d0e",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"from datetime import datetime\n",
"\n",
"# ── Lưu mô hình PyTorch ────────────────────────────────────────────────────────\n",
"model_path = \"model_mobilenet_land_use.pth\"\n",
"torch.save(model.state_dict(), model_path)\n",
"print(f\"✅ Model saved → {model_path}\")\n",
"\n",
"# ── Lưu thông tin mô hình ──────────────────────────────────────────────────────\n",
"info = {\n",
" \"model_type\": \"MobileNetV3_LR-ASPP\",\n",
" \"n_features\": n_features,\n",
" \"n_classes\": n_classes,\n",
" \"learning_rate\": LEARNING_RATE,\n",
" \"batch_size\": BATCH_SIZE,\n",
" \"max_epochs\": N_EPOCHS,\n",
" \"early_stopping_patience\": PATIENCE,\n",
" \"optimizer\": \"Adam\",\n",
" \"scheduler\": \"ReduceLROnPlateau(factor=0.5, patience=5)\",\n",
" \"class_weight\": \"balanced\",\n",
" \"label_mapping\": label_mapping,\n",
" \"test_accuracy\": float(acc),\n",
" \"train_samples\": len(X_train_np),\n",
" \"val_samples\": len(X_val_np),\n",
" \"test_samples\": len(X_test_np),\n",
" \"saved_at\": datetime.now().isoformat(),\n",
"}\n",
"info_path = \"model_mobilenet_land_use_info.json\"\n",
"with open(info_path, \"w\") as f:\n",
" json.dump(info, f, indent=2, ensure_ascii=False)\n",
"print(f\"✅ Info saved → {info_path}\")\n",
"print(json.dumps(info, indent=2, ensure_ascii=False))\n",
"\n",
"# ── Đóng kết nối Dask ──────────────────────────────────────────────────────────\n",
"try:\n",
" client.close()\n",
" cluster.close()\n",
" print(\"✅ Dask cluster closed.\")\n",
"except Exception:\n",
" pass\n"
]
}
],
"metadata": {