"""Optional NEW training of unsaved configurations; never impersonates old runs. Example: python scripts/train_missing_deep.py --model Embedding+CNN All missing: python scripts/train_missing_deep.py --all-missing Use a GPU environment for the full sweep. Test is not read during training. """ from pathlib import Path import sys,os,json,pickle,argparse,gc ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT)) os.environ.setdefault('TF_CPP_MIN_LOG_LEVEL','2') import numpy as np import pandas as pd import tensorflow as tf from model_registry import registry,slug def build(spec,vocab,embedding): L=tf.keras.layers;inputs=L.Input(shape=(52,)) kwargs={'weights':[embedding]} if embedding is not None else {} x=L.Embedding(vocab,300,trainable=True,**kwargs)(inputs) architecture=spec['architecture'];family=spec['family'] if family=='CNN First':x=L.Conv1D(128,3,activation='relu')(x) recurrent=[s for s in architecture.split('+') if s in ('BiLSTM','BiGRU')] for i,name in enumerate(recurrent): cls=L.LSTM if name=='BiLSTM' else L.GRU returns=(family!='No CNN' or i