<jupyter_start><jupyter_text>Creating an unbiased train/valid split1. How biased is a simple <2016/2016 split? Answer: There doesn't seem to be a large bias. This means I can simply use this split to test for overfitting.<jupyter_code>%load_ext autoreload
%autoreload 2
from src.train_nn import *
import matplotlib.pyplot as plt
limit_mem()
datadir = '/data/weather-benchmark/5.625deg/'
z = xr.open_mfdataset(f'{datadir}geopotential_500/*.nc', combine='by_coords')
t = xr.open_mfdataset(f'{datadir}temperature_850/*.nc', combine='by_coords')
ds = xr.merge([z, t])<jupyter_output><empty_output><jupyter_text>How biased is a simple <2016/2016 split?<jupyter_code>ds_train = ds.sel(time=slice('1979', '2015'))
ds_valid = ds.sel(time=slice('2016', '2016'))
ds_test = ds.sel(time=slice('2017', '2018'))
dic = {'z': None, 't': None}
batch_size = 32
lead_time = 3*24
dummy = DataGenerator(ds_train.isel(time=slice(0, None, 5*12)), dic, lead_time, batch_size=batch_size, shuffle=False)
dg_train = DataGenerator(ds_train, dic, lead_time, batch_size=batch_size, mean=dummy.mean,
                         std=dummy.std, shuffle=False)
dg_valid = DataGenerator(ds_valid, dic, lead_time, batch_size=batch_size, mean=dg_train.mean,
                         std=dg_train.std, shuffle=False)
dg_test =  DataGenerator(ds_test, dic, lead_time, batch_size=batch_size, mean=dg_train.mean,
                         std=dg_train.std, shuffle=False)
dg_fake =  DataGenerator(ds_test.sel(time='2018'), dic, lead_time, batch_size=batch_size, mean=dg_train.mean,
                         std=dg_train.std)
model = build_cnn([64, 64, 64, 64, 2], [5, 5, 5, 5, 5], input_shape=(32, 64, 2), activation='elu')
model.compile(keras.optimizers.Adam(), 'mse')
model.fit_generator(dg_fake, epochs=1)
model.evaluate_generator(dg_train, verbose=1)
model.evaluate_generator(dg_valid, verbose=1)
model.evaluate_generator(dg_test, verbose=1)
# Create predictions from an untrained model
preds_train = create_predictions(model, dg_train)
preds_valid = create_predictions(model, dg_valid)
preds_test = create_predictions(model, dg_test)
rmse_train = compute_weighted_rmse(preds_train.isel(time=slice(0, None, 36)), ds).load(); rmse_train
rmse_valid = compute_weighted_rmse(preds_valid, ds).load(); rmse_valid
rmse_test = compute_weighted_rmse(preds_test, ds).load(); rmse_test
len(dg_train), len(dg_valid)
mses_train = []
for i in range(len(dg_valid))[::-1]:
    x, y = dg_train[-i]
    p = model.predict_on_batch(x)
    mses_train.append(((y - p)**2).mean())
mses_valid = []
for i in range(len(dg_valid)):
    x, y = dg_valid[i]
    p = model.predict_on_batch(x)
    mses_valid.append(((y - p)**2).mean())
plt.plot(mses_train)
plt.plot(mses_valid)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1425959780621572, 'fraction_numerical': 0.03436928702010969, 'mean_word_length': 5.576923076923077, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '588805', 'license': 'MIT', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1003, 'n_words': 199, 'path': 'devlog/01-validation_split.ipynb', 'repo_name': 'pzharrington/WeatherBench', 'size': '2735'}