[context33] - increase momentum 0.5→0.7; run outputs 99% recon, 88% next-step

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 20:06:20 +02:00
co-authored by Claude Sonnet 4.6
parent 586803856f
commit 4a915f165a
4 changed files with 472 additions and 374 deletions
+210 -150
View File
File diff suppressed because one or more lines are too long
+237 -167
View File
File diff suppressed because one or more lines are too long
+22 -54
View File
@@ -11,8 +11,8 @@
"shell.execute_reply": "2026-05-31T13:42:50.945911Z" "shell.execute_reply": "2026-05-31T13:42:50.945911Z"
}, },
"ExecuteTime": { "ExecuteTime": {
"end_time": "2026-05-31T18:01:00.462677288Z", "end_time": "2026-05-31T18:06:04.806316893Z",
"start_time": "2026-05-31T18:01:00.408293980Z" "start_time": "2026-05-31T18:06:04.717164306Z"
} }
}, },
"source": [ "source": [
@@ -32,7 +32,7 @@
"from rbm.status import CheckpointStatus" "from rbm.status import CheckpointStatus"
], ],
"outputs": [], "outputs": [],
"execution_count": 27 "execution_count": 47
}, },
{ {
"cell_type": "code", "cell_type": "code",
@@ -45,8 +45,8 @@
"shell.execute_reply": "2026-05-31T13:42:50.952461Z" "shell.execute_reply": "2026-05-31T13:42:50.952461Z"
}, },
"ExecuteTime": { "ExecuteTime": {
"end_time": "2026-05-31T18:01:00.511288729Z", "end_time": "2026-05-31T18:06:04.880711653Z",
"start_time": "2026-05-31T18:01:00.463411358Z" "start_time": "2026-05-31T18:06:04.841414824Z"
} }
}, },
"source": [ "source": [
@@ -54,7 +54,7 @@
"SENSORY_SIZE = 40 # numVisibleX * numVisibleY = 1 * 40\n", "SENSORY_SIZE = 40 # numVisibleX * numVisibleY = 1 * 40\n",
"CONTEXT_SIZE = 256 # numContext = numHidden\n", "CONTEXT_SIZE = 256 # numContext = numHidden\n",
"LEARNING_RATE = 0.05 # learningRate\n", "LEARNING_RATE = 0.05 # learningRate\n",
"MOMENTUM = 0.5 # momentum\n", "MOMENTUM = 0.7 # momentum\n",
"NUM_EPOCHS = 100 # numEpochs\n", "NUM_EPOCHS = 100 # numEpochs\n",
"MINI_BATCH = 100 # miniBatchSize\n", "MINI_BATCH = 100 # miniBatchSize\n",
"NUM_GIBBS = 3 # numGibbs\n", "NUM_GIBBS = 3 # numGibbs\n",
@@ -71,7 +71,7 @@
"char_to_idx = {c: i for i, c in enumerate(chars)}" "char_to_idx = {c: i for i, c in enumerate(chars)}"
], ],
"outputs": [], "outputs": [],
"execution_count": 28 "execution_count": 48
}, },
{ {
"cell_type": "code", "cell_type": "code",
@@ -84,8 +84,8 @@
"shell.execute_reply": "2026-05-31T13:42:50.958632Z" "shell.execute_reply": "2026-05-31T13:42:50.958632Z"
}, },
"ExecuteTime": { "ExecuteTime": {
"end_time": "2026-05-31T18:01:00.570664090Z", "end_time": "2026-05-31T18:06:04.938144862Z",
"start_time": "2026-05-31T18:01:00.512242185Z" "start_time": "2026-05-31T18:06:04.881644183Z"
} }
}, },
"source": "# ── Training sentence ──────────────────────────────────────────────────────\nSENTENCE = (\n \"Call me Ishmael. Some years ago, never mind how long precisely, \"\n \"having little money in my pocket and nothing particular to interest \"\n \"me on shore, I thought I would sail about a little.\"\n)\n\n# Convert to uppercase, keep only in-vocab characters\nSENTENCE = ''.join(c for c in SENTENCE.upper() if c in ALLOWED)\nN_SAMPLES = len(SENTENCE)\n\nsensory_np = np_cpu.zeros((N_SAMPLES, SENSORY_SIZE), dtype=np_cpu.float64)\nfor i, c in enumerate(SENTENCE):\n sensory_np[i, char_to_idx[c]] = 1.0\n\ndecoded = SENTENCE\nprint(f\"Sentence : '{decoded}'\")\nprint(f\"Length : {N_SAMPLES} chars\")", "source": "# ── Training sentence ──────────────────────────────────────────────────────\nSENTENCE = (\n \"Call me Ishmael. Some years ago, never mind how long precisely, \"\n \"having little money in my pocket and nothing particular to interest \"\n \"me on shore, I thought I would sail about a little.\"\n)\n\n# Convert to uppercase, keep only in-vocab characters\nSENTENCE = ''.join(c for c in SENTENCE.upper() if c in ALLOWED)\nN_SAMPLES = len(SENTENCE)\n\nsensory_np = np_cpu.zeros((N_SAMPLES, SENSORY_SIZE), dtype=np_cpu.float64)\nfor i, c in enumerate(SENTENCE):\n sensory_np[i, char_to_idx[c]] = 1.0\n\ndecoded = SENTENCE\nprint(f\"Sentence : '{decoded}'\")\nprint(f\"Length : {N_SAMPLES} chars\")",
@@ -99,7 +99,7 @@
] ]
} }
], ],
"execution_count": 29 "execution_count": 49
}, },
{ {
"cell_type": "code", "cell_type": "code",
@@ -112,8 +112,8 @@
"shell.execute_reply": "2026-05-31T13:42:51.207444Z" "shell.execute_reply": "2026-05-31T13:42:51.207444Z"
}, },
"ExecuteTime": { "ExecuteTime": {
"end_time": "2026-05-31T18:01:00.981089507Z", "end_time": "2026-05-31T18:06:05.261711758Z",
"start_time": "2026-05-31T18:01:00.571331995Z" "start_time": "2026-05-31T18:06:04.939234537Z"
} }
}, },
"source": [ "source": [
@@ -146,7 +146,7 @@
} }
} }
], ],
"execution_count": 30 "execution_count": 50
}, },
{ {
"cell_type": "code", "cell_type": "code",
@@ -159,8 +159,8 @@
"shell.execute_reply": "2026-05-31T13:42:51.212592Z" "shell.execute_reply": "2026-05-31T13:42:51.212592Z"
}, },
"ExecuteTime": { "ExecuteTime": {
"end_time": "2026-05-31T18:01:01.035739430Z", "end_time": "2026-05-31T18:06:05.316035425Z",
"start_time": "2026-05-31T18:01:00.981681957Z" "start_time": "2026-05-31T18:06:05.262504600Z"
} }
}, },
"source": "# ── Prepare sequences for StackRnn ─────────────────────────────────────────\n# Tile the single sentence N_REPEAT times to form a real batch so GPU/CPU\n# matrix ops are (N_REPEAT, 168) instead of (1, 168).\nN_REPEAT = 500\nsequences = np_cpu.tile(sensory_np[np_cpu.newaxis, :, :], (N_REPEAT, 1, 1))\nprint(f\"sequences shape : {sequences.shape} → {N_REPEAT} × {N_SAMPLES} chars\")", "source": "# ── Prepare sequences for StackRnn ─────────────────────────────────────────\n# Tile the single sentence N_REPEAT times to form a real batch so GPU/CPU\n# matrix ops are (N_REPEAT, 168) instead of (1, 168).\nN_REPEAT = 500\nsequences = np_cpu.tile(sensory_np[np_cpu.newaxis, :, :], (N_REPEAT, 1, 1))\nprint(f\"sequences shape : {sequences.shape} → {N_REPEAT} × {N_SAMPLES} chars\")",
@@ -173,7 +173,7 @@
] ]
} }
], ],
"execution_count": 31 "execution_count": 51
}, },
{ {
"cell_type": "code", "cell_type": "code",
@@ -186,8 +186,8 @@
"shell.execute_reply": "2026-05-31T13:42:51.319006Z" "shell.execute_reply": "2026-05-31T13:42:51.319006Z"
}, },
"ExecuteTime": { "ExecuteTime": {
"end_time": "2026-05-31T18:01:01.087502997Z", "end_time": "2026-05-31T18:06:05.384091288Z",
"start_time": "2026-05-31T18:01:01.036405964Z" "start_time": "2026-05-31T18:06:05.327317819Z"
} }
}, },
"source": [ "source": [
@@ -234,7 +234,7 @@
] ]
} }
], ],
"execution_count": 32 "execution_count": 52
}, },
{ {
"cell_type": "code", "cell_type": "code",
@@ -247,7 +247,7 @@
"shell.execute_reply": "2026-05-31T13:44:35.696410Z" "shell.execute_reply": "2026-05-31T13:44:35.696410Z"
}, },
"ExecuteTime": { "ExecuteTime": {
"start_time": "2026-05-31T18:01:01.094798239Z" "start_time": "2026-05-31T18:06:05.385095367Z"
} }
}, },
"source": [ "source": [
@@ -304,40 +304,8 @@
"text": [ "text": [
"-------------------------------------------\n", "-------------------------------------------\n",
"Entity-296x256: progress : 1%\n", "Entity-296x256: progress : 1%\n",
"Entity-296x256: err_rms : 0.0002205270517712705\n", "Entity-296x256: err_rms : 4.153017505591589e-06\n",
"Entity-296x256: l2_norm : 142.99783613789947\n", "Entity-296x256: l2_norm : 149.9841498059769\n"
"-------------------------------------------\n",
"Entity-296x256: progress : 11%\n",
"Entity-296x256: err_rms : 5.279407091985102e-06\n",
"Entity-296x256: l2_norm : 143.43850704438344\n",
"-------------------------------------------\n",
"Entity-296x256: progress : 21%\n",
"Entity-296x256: err_rms : 4.5788413842108285e-06\n",
"Entity-296x256: l2_norm : 143.87610314823223\n",
"-------------------------------------------\n",
"Entity-296x256: progress : 31%\n",
"Entity-296x256: err_rms : 4.457335070322053e-06\n",
"Entity-296x256: l2_norm : 144.2866792344391\n",
"-------------------------------------------\n",
"Entity-296x256: progress : 41%\n",
"Entity-296x256: err_rms : 4.415657584538288e-06\n",
"Entity-296x256: l2_norm : 144.68009848927727\n",
"-------------------------------------------\n",
"Entity-296x256: progress : 51%\n",
"Entity-296x256: err_rms : 4.39380821377769e-06\n",
"Entity-296x256: l2_norm : 145.060477619678\n",
"-------------------------------------------\n",
"Entity-296x256: progress : 61%\n",
"Entity-296x256: err_rms : 4.377943875271283e-06\n",
"Entity-296x256: l2_norm : 145.43015581564566\n",
"-------------------------------------------\n",
"Entity-296x256: progress : 71%\n",
"Entity-296x256: err_rms : 4.363603864787239e-06\n",
"Entity-296x256: l2_norm : 145.79070936590585\n",
"-------------------------------------------\n",
"Entity-296x256: progress : 81%\n",
"Entity-296x256: err_rms : 4.34883619751348e-06\n",
"Entity-296x256: l2_norm : 146.14331420811664\n"
] ]
} }
], ],
+3 -3
View File
@@ -10,12 +10,12 @@ from rbm.matrix import Mat, np, convert
from rbm.status import CheckpointStatus from rbm.status import CheckpointStatus
DATA_DIR = '/media/jens/cifs/bilder/MachineVision/Caltech_WebFaces/' DATA_DIR = '/media/jens/cifs/bilder/MachineVision/Caltech_WebFaces/'
PATCH = 32 PATCH = 8
STRIDE = 16 # 50% overlap; set equal to PATCH for non-overlapping STRIDE = 4 # 50% overlap; set equal to PATCH for non-overlapping
GRAYSCALE = False # reassigned in __main__ when --grayscale is set GRAYSCALE = False # reassigned in __main__ when --grayscale is set
N_CH = 1 if GRAYSCALE else 3 N_CH = 1 if GRAYSCALE else 3
N_VIS = N_CH * PATCH * PATCH # 1024 grayscale / 3072 colour N_VIS = N_CH * PATCH * PATCH # 1024 grayscale / 3072 colour
N_HID = 256 N_HID = 64
N_IMAGES = 50 N_IMAGES = 50