Skip to content

Instantly share code, notes, and snippets.

@GINK03
Last active July 4, 2018 05:06
Show Gist options
  • Save GINK03/6f88a235c617f04a0019729eafe618bb to your computer and use it in GitHub Desktop.
Save GINK03/6f88a235c617f04a0019729eafe618bb to your computer and use it in GitHub Desktop.
kerasで動的にlearning rateを構築する

kerasのbackendで設定する必要があって、いくつか過去のレポジトリを修正しなくては行けない可能性がある

from sklearn.cross_validation import KFold
import swap_noise
from keras import backend as K 

for i in range(100):
    NFOLDS=100
    SEED=777
    kf = KFold(len(df.values), n_folds=NFOLDS, shuffle=True, random_state=SEED)
    for i, (train_index, test_index) in enumerate(kf):
        noised = swap_noise.noise(df.values)
        dae.fit(noised[train_index], df.values[train_index],
                        epochs=1,
                        validation_data=(noised[test_index], df.values[test_index]),
                        batch_size=6000,
                        shuffle=True,)
        lr = 0.01*( (NFOLDS - i)/NFOLDS )
        K.set_value(dae.optimizer.lr, lr)
    dae.save_weights('vars/dae.h5')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment