The file train.py trains a two-stacked-LSTMCell Sequence model on sine waves using LBFGS (closure-based optimizer). Sine waves are generated with random phase shifts using numpy.
Your task is to port this as a two-stage pipeline:
Stage 1 – generate_sine_data: Given a seed, N curves, and sequence length L, generate a numpy sine wave dataset (each curve has phase sampled from U[0, 2π]). Return the data as a nested list (for JSON serialization).
Stage 2 – run_lbfgs_training: Given the data (as a nested list), build the Sequence model with double precision, run n_steps LBFGS closure steps on the training split (first N-1 curves), evaluate on the test split (last curve), return: initial training loss, final training loss, test loss.