committed first notebook on training the model
This commit is contained in:
parent
2aa09b2de2
commit
ee1695c7fa
133
Training_IC_on_Demand.ipynb
Normal file
133
Training_IC_on_Demand.ipynb
Normal file
@ -0,0 +1,133 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f7c63b6e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Create ICs on Demand"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "7fefd6b2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pylab as plt\n",
|
||||
"\n",
|
||||
"from models.multiresolution_flow_3d import *\n",
|
||||
"from models.trainer import *\n",
|
||||
"\n",
|
||||
"%matplotlib inline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e5aa8c20",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Setup the model"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "3d84fb99",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"(32, 32, 32)\n",
|
||||
"Trainer model: tm\n",
|
||||
"load initial state\n",
|
||||
"save initial state\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"nlevel=5\n",
|
||||
"\n",
|
||||
"shape = (2**nlevel,2**nlevel,2**nlevel)\n",
|
||||
"\n",
|
||||
"model = multi_scale_model(nlevel=nlevel)\n",
|
||||
"\n",
|
||||
"tm = trainer(model)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "476e8808",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# test training with white noise"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "bba2858b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Train model...\n",
|
||||
"test [[[3.14149864]]]\n",
|
||||
"Training done\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"0"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for i in np.arange(100):\n",
|
||||
" x_train = np.random.normal(0,0.01,shape)+3.1415\n",
|
||||
" tm.train_single(x_train, silent=True)\n",
|
||||
"tm.transfer(silent=False)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "75b0b971",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"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.9.7"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
Loading…
Reference in New Issue
Block a user