def main(_): console.suppress_logging() FLAGS.overwrite = True FLAGS.train = True # Start console.start() # Get or define model model = models.vanilla('vanilla_nov9_02_h2_c', bn=False) # model = models.dcgan('dcgan_c00') # model = models.vanilla_h3_rs_nbn('vanilla_nov9_01_h3_nbn_opdef') # return # Train or test if FLAGS.train: mnist = load_mnist('../../data/MNIST', flatten=True, validation_size=0, one_hot=True) model.train(training_set=mnist[pedia.training], epoch=1000, batch_size=128, print_cycle=20, snapshot_cycle=150, sample_num=25) else: samples = model.generate(sample_num=16) console.show_status('{} samples generated'.format(samples.shape[0])) imtool.gan_grid_plot(samples, show=True) # End console.end()
def activate(): # This line must be put in activate th.output_dim = 2**th.bits assert callable(th.model) model = th.model(th) assert isinstance(model, Predictor) # Load data train_set, val_set, test_set = du.load(th.data_dir, th.sequence_length, th.bits, th.fixed_length, th.val_size, th.test_size) # Train if th.train: # Training will be terminated once all sequences in validating set has # .. been classified correctly model.train(train_set, validation_set=val_set, trainer_hub=th, terminator=lambda metric: metric == 1.0) else: model.evaluate_model(test_set) # End model.shutdown() console.end()
def activate(): assert callable(th.model) model = th.model(th) assert isinstance(model, Classifier) # Load data train_set, val_set, test_set = du.load_data(th.data_dir) assert isinstance(train_set, SequenceSet) assert isinstance(val_set, SequenceSet) assert isinstance(test_set, SequenceSet) # Train or evaluate if th.train: model.train(train_set, validation_set=val_set, trainer_hub=th, test_set=test_set) else: # Evaluate model model.evaluate_model(train_set, batch_size=5000) model.evaluate_model(val_set, batch_size=5000) model.evaluate_model(test_set, batch_size=5000) # End model.shutdown() console.end()
def activate(): assert callable(th.model) model = th.model(th) assert isinstance(model, Classifier) input_dim = th.input_shape[0] init_f = init_methods.brutal_chop(input_dim) round_len_f = init_methods.brutal_chop_len_f(input_dim) # Load data train_set, val_set = du.load_balanced_data(tfr_v_8000, train_size, val_size, init_f=init_f, round_len_f=round_len_f) train_set.initialize(input_dim, batches_per_epoch) # Train or evaluate if th.train: model.train(train_set, validation_set=val_set, trainer_hub=th) # x # model.train(train_set, validation_set=train_set, trainer_hub=th) # model.train(val_set, validation_set=val_set, trainer_hub=th) else: model.evaluate_model(train_set) model.evaluate_model(val_set) # End console.end()
def main(_): # Configuration # FLAGS.train = False # FLAGS.smart_train = True FLAGS.overwrite = True FLAGS.summary = True FLAGS.save_model = False FLAGS.snapshot = False MEMORY_DEPTH = 1 EPOCH = 2 # Start console.start('rnn_task') # Initiate model model = rnn_models.vanilla_RNN('rnn00') # Load data train_set, val_set, test_set = load_wiener_hammerstein( r'../data/wiener_hammerstein/whb.tfd', depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train or evaluate if FLAGS.train: pass else: console.show_status('Evaluating ...') # End console.end()
def main(_): FLAGS.overwrite = False FLAGS.train = True play = True console.suppress_logging() console.start('TD Gomoku - vanilla') with tf.Graph().as_default(): model = models.mlp00('mlp00_00') with tf.Graph().as_default(): opponent = models.mlp00('mlp00_00') game = Game() if FLAGS.train: model.train(game, episodes=500000, print_cycle=20, snapshot_cycle=300, match_cycle=2000, rounds=5, rate_thresh=1.0, shadow=opponent, save_cycle=200, snapshot_function=game.snapshot) else: if play: TkBoard(player=model).show() else: model.compete(game, rounds=100, opponent=opponent) console.end()
def main(_): console.suppress_logging() # Setting FLAGS.train = False FLAGS.overwrite = True # FLAGS.shuffle = True show_false_pred = True # Start console.start('CIFAR-10 CONV DEMO') # Get model # model = models.deep_conv('dper_do0p5_reg0p2') model = models.deep_conv('001_pre_bn') # Train or test cifar10 = load_cifar10('../../data/CIFAR-10', flatten=False, validation_size=5000, one_hot=True) if FLAGS.train: model.train(training_set=cifar10[pedia.training], validation_set=cifar10[pedia.validation], epoch=120, batch_size=64, print_cycle=100) else: model.evaluate_model(cifar10[pedia.test], with_false=show_false_pred) # End console.end()
def activate(): # Load data train_set, val_set, test_set = du.load_data(th.data_dir, th.val_size, th.test_size) th.train_set = train_set # Build model assert callable(th.model) model = th.model(th) assert isinstance(model, Classifier) # Train or evaluate if th.train: model.train(train_set, validation_set=val_set, test_set=test_set, trainer_hub=th) elif th.dynamic_evaluation: model.evaluate_model(test_set, dynamic=True, val_set=val_set) else: model.evaluate_model(train_set, batch_size=1) model.evaluate_model(val_set, batch_size=1) model.evaluate_model(test_set, batch_size=1) # End model.shutdown() console.end()
def activate(export_false=False): # Load data train_set, val_set, test_set = du.load_data(th.data_dir) if th.centralize_data: th.data_mean = train_set.feature_mean # Build model assert callable(th.model) model = th.model(th) assert isinstance(model, Classifier) # Train or evaluate if th.train: model.train(train_set, validation_set=val_set, trainer_hub=th, test_set=test_set) else: bs = 5000 model.evaluate_model(train_set, batch_size=bs) model.evaluate_model(val_set, batch_size=bs) model.evaluate_model(test_set, export_false=export_false, batch_size=bs) # End model.shutdown() console.end()
def main(_): console.suppress_logging() FLAGS.train = TRAIN FLAGS.overwrite = OVERWRITE console.start('EXP OB 01') # Define system system = define_system() # Generate data training_set, validation_set, test_set = generate_data(system) if len(SYS_LOCK_ORDERS) == 1: homogeneous_check(system, SYS_LOCK_ORDERS[0], training_set.signls[0], training_set.responses[0]) # Identification # .. wiener wiener = Wiener(degree=WN_DEGREE, memory_depth=WN_MEN_DEPTH) if WIENER_ON: wiener.identify(training_set, validation_set) # .. vn homo_strs = NN_HOMO_STRS vns = collections.OrderedDict() for homo_str in homo_strs: console.show_status('Volterra Net h**o-strength = {:.2f}'.format(homo_str)) vn = init_vn('vn_{:.2f}{}'.format(homo_str, POSTFIX), homo_str=homo_str) vns[homo_str] = vn if FLAGS.train: vn.identify(training_set, validation_set, batch_size=50, print_cycle=100, epoch=EPOCH) # Verification verify(vns, wiener, system, test_set) # End console.end()
def main(_): console.suppress_logging() FLAGS.train = True FLAGS.overwrite = False # Start console.start("MNIST DCGAN DEMO") # Get model model = models.dcgan('dcgan_002') # model = models.dcgan_h3_rs_nbn() # Train or test if FLAGS.train: mnist = load_mnist('../../data/MNIST', flatten=False, validation_size=0, one_hot=True) model.train(training_set=mnist[pedia.training], epoch=10, batch_size=128, print_cycle=20, snapshot_cycle=200, D_times=1, G_times=1) else: samples = model.generate(sample_num=16) console.show_status('{} samples generated'.format(samples.shape[0])) imtool.gan_grid_plot(samples, show=True) # End console.end()
def activate(): if th.rand_pos: th.mark += '_rand_pos' assert callable(th.model) model = th.model(th) # assert isinstance(model, ) # Load data path = '../data/processed_data/' if not th.modify_train_ver_n: train_set, val_set, test_set, all_train_set, train_split = GPAT.load_data_set( path, th, random_pos=th.rand_pos, test_all=th.test_all) else: test_set = GPAT.load_ver_n_data(path, id=1) # Train or evaluate if th.train and not th.val_on_train_set: model.train(train_set, validation_set=val_set, trainer_hub=th) if not th.train and not th.val_on_train_set: model.launch_model(overwrite=False) # evaluate(model, test_set, th, scores=True) if not th.modify_train_ver_n: GPAT.evaluate(model, test_set, th, save_prods=True) else: cor_inds, false_inds = model.evaluate_model( test_set, batch_size=th.val_batch_size) pickle_data(cor_inds, os.path.join('./indices', th.mark + '.pkl')) if th.val_on_train_set: model.evaluate_model(val_set, batch_size=th.val_batch_size) # End console.end()
def main(_): console.suppress_logging() FLAGS.train = False FLAGS.overwrite = True show_false = True flatten = False # Start console.start('MNIST DEMO') # model = models.vanilla('003_post') model = models.deep_conv('dc_000') mnist = load_mnist('../../data/MNIST', flatten=flatten, validation_size=5000, one_hot=True) # Train or test if FLAGS.train: model.train(training_set=mnist[pedia.training], validation_set=mnist[pedia.validation], epoch=30, batch_size=100, print_cycle=50) else: model.evaluate_model(mnist[pedia.test], with_false=show_false) # End console.end()
def activate(): # Load datasets train_set, val_set, test_set = du.load_data(th.data_dir) # Calculate class weights if th.class_weights is None and th.loss_string == 'wce': train_targets = train_set.stack.targets.flatten() samples_per_class = [ sum(train_targets == c) for c in range(th.num_classes) ] class_weights = min(samples_per_class) / np.array(samples_per_class) th.class_weights = class_weights console.show_status('Class weights set to {}'.format(th.class_weights), '++') # Set input shape according to th.max_level and th.volume_only du.FI2010.set_input_shape() # Build model assert callable(th.model) model = th.model(th) assert isinstance(model, Classifier) # Train or evaluate if th.train: model.train(train_set, validation_set=val_set, test_set=test_set, trainer_hub=th, evaluate=lambda t: du.FI2010.evaluate(t, test_set)) else: du.FI2010.evaluate(model, test_set) # End model.shutdown() console.end()
def main(_): console.start('RNN task') # Configurations th = NlsHub(as_global=True) th.memory_depth = 10 th.num_blocks = 1 th.multiplier = 8 th.hidden_dim = th.memory_depth * th.multiplier th.num_steps = 32 th.epoch = 100000 th.batch_size = 32 th.learning_rate = 1e-4 th.validation_per_round = 20 th.print_cycle = 0 # th.train = False th.smart_train = True th.max_bad_apples = 4 th.lr_decay = 0.6 th.early_stop = True th.idle_tol = 20 th.save_mode = SaveMode.ON_RECORD th.warm_up_thres = 1 th.at_most_save_once_per_round = True th.overwrite = True # Default: False th.export_note = True th.summary = True th.monitor_preact = False th.save_model = True th.allow_growth = False th.gpu_memory_fraction = 0.4 description = '0' th.mark = 'rnn-{}x({}x{})-{}steps-{}'.format( th.num_blocks, th.memory_depth, th.multiplier, th.num_steps, description) # Get model model = model_lib.rnn0(th) # Load data train_set, val_set, test_set = load_wiener_hammerstein( th.data_dir, depth=th.memory_depth, validation_size=2000) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train or evaluate if th.train: model.nn.train(train_set, validation_set=val_set, trainer_hub=th) else: console.show_status('Evaluating ...') model.evaluate(train_set, start_at=th.memory_depth) model.evaluate(val_set, start_at=th.memory_depth) model.evaluate(test_set, start_at=th.memory_depth) # End console.end()
def main(_): console.suppress_logging() FLAGS.train = True FLAGS.overwrite = False # Start console.start('CIFAR-10 DCGAN') # Get model model = models.dcgan('dcgan_00') if FLAGS.train: cifar10 = load_cifar10('../../data/CIFAR-10', validation_size=0, one_hot=True) model.train(training_set=cifar10[pedia.training], epoch=20000, batch_size=128, print_cycle=20, snapshot_cycle=2000) else: samples = model.generate(sample_num=16) console.show_status('{} samples generated'.format(samples.shape[0])) imtool.gan_grid_plot(samples, show=True) # End console.end()
def main(_): console.suppress_logging() FLAGS.train = True FLAGS.overwrite = True # Start console.start('MNIST VANILLA VAE') # Get model model = models.vanilla('vanilla_00') if FLAGS.train: mnist = load_mnist('../../data/MNIST', flatten=True, validation_size=0, one_hot=True) model.train(training_set=mnist[pedia.training], epoch=1000, batch_size=128, print_cycle=50, snapshot_cycle=200) else: samples = model.generate(sample_num=16) console.show_status('{} samples generated'.format(samples.shape[0])) imtool.gan_grid_plot(samples, show=True) # End console.end()
def main(_): console.start('mlp task') # Configurations th = NlsHub(as_global=True) th.memory_depth = 6 th.num_blocks = 2 th.multiplier = 2 th.hidden_dim = th.memory_depth * th.multiplier # th.actype1 = 'lrelu' # Default: relu th.epoch = 10 th.batch_size = 32 th.learning_rate = 1e-4 th.validation_per_round = 5 th.print_cycle = 100 th.train = True # th.smart_train = True # th.max_bad_apples = 4 # th.lr_decay = 0.6 th.early_stop = True th.idle_tol = 20 th.save_mode = SaveMode.NAIVE # th.warm_up_thres = 1 # th.at_most_save_once_per_round = True th.overwrite = True th.export_note = True th.summary = False # th.monitor = True th.save_model = True th.allow_growth = False th.gpu_memory_fraction = 0.40 description = '0' th.mark = 'mlp-{}x({}x{})-{}'.format(th.num_blocks, th.memory_depth, th.multiplier, description) # Get model model = nlsf_model_lib.mlp_00(th) # Load data train_set, val_set, test_set = load_data(th.data_dir, depth=th.memory_depth) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train or evaluate if th.train: model.nn.train(train_set, validation_set=val_set, trainer_hub=th) else: console.show_status('Evaluating ...') model.evaluate(train_set, start_at=th.memory_depth) model.evaluate(val_set, start_at=th.memory_depth) model.evaluate(test_set, start_at=th.memory_depth, plot=True) # End console.end()
def main(_): console.start('trainer.task') EPOCH = 1000 # FLAGS.train = False FLAGS.overwrite = True # FLAGS.save_best = True FLAGS.smart_train = True # Hyper parameters LEARNING_RATE = 0.001 LAYER_NUM = 4 BATCH_SIZE = 32 MEMORY_DEPTH = 80 LAYER_DIM = MEMORY_DEPTH * 2 ACTIVATION = 'relu' # Set default flags FLAGS.progress_bar = True FLAGS.save_model = True FLAGS.summary = False FLAGS.snapshot = False PRINT_CYCLE = 100 WH_PATH = os.path.join(nls_root, 'data/wiener_hammerstein/whb.tfd') MARK = 'mlp00' # Get model model = model_lib.mlp_00(MARK, MEMORY_DEPTH, LAYER_DIM, LAYER_NUM, LEARNING_RATE, activation=ACTIVATION) # Load data set train_set, val_set, test_set = load_wiener_hammerstein(WH_PATH, depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train or evaluate if FLAGS.train: model.identify(train_set, val_set, batch_size=BATCH_SIZE, print_cycle=PRINT_CYCLE, epoch=EPOCH) else: model.evaluate(train_set, start_at=MEMORY_DEPTH, plot=False) model.evaluate(val_set, start_at=MEMORY_DEPTH, plot=False) model.evaluate(test_set, start_at=MEMORY_DEPTH, plot=False) console.end()
def main(_): console.start('BResNet task') description = '0' # Configurations th = NlsHub(as_global=True) th.memory_depth = 80 th.num_blocks = 3 th.multiplier = 1 th.hidden_dim = th.memory_depth * th.multiplier th.mark = 'bres-{}x({}x{})-{}'.format(th.num_blocks, th.memory_depth, th.multiplier, description) th.epoch = 50000 th.batch_size = 64 th.learning_rate = 0.0001 th.start_at = 0 th.reg_strength = 0.000 th.validation_per_round = 30 th.train = True th.smart_train = True th.idle_tol = 30 th.max_bad_apples = 5 th.lr_decay = 0.6 th.early_stop = True th.save_mode = SaveMode.ON_RECORD th.warm_up_rounds = 50 th.overwrite = True th.export_note = True th.summary = False th.save_model = False # Smoothen th.overwrite = th.overwrite and th.start_at == 0 # Get model model = model_lib.bres_net_res0(th) # Load data train_set, val_set, test_set = load_wiener_hammerstein( th.data_dir, depth=th.memory_depth) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train or evaluate if th.train: model.nn.train(train_set, validation_set=val_set, trainer_hub=th, start_at=th.start_at) else: model.evaluate(train_set, start_at=th.memory_depth) model.evaluate(val_set, start_at=th.memory_depth) model.evaluate(test_set, start_at=th.memory_depth) # End console.end()
def main(_): console.start('mlp task') description = 'm' # Configurations th = NlsHub(as_global=True) th.memory_depth = 40 th.num_blocks = 2 th.multiplier = 2 th.hidden_dim = th.memory_depth * th.multiplier th.mark = 'mlp-{}x({}x{})-{}'.format(th.num_blocks, th.memory_depth, th.multiplier, description) th.epoch = 50000 th.batch_size = 64 th.learning_rate = 0.001 th.validation_per_round = 20 th.train = True th.smart_train = False th.idle_tol = 20 th.max_bad_apples = 4 th.lr_decay = 0.6 th.early_stop = True th.save_mode = SaveMode.ON_RECORD th.warm_up_rounds = 50 th.overwrite = True th.export_note = True th.summary = True th.monitor = True th.save_model = False th.allow_growth = False th.gpu_memory_fraction = 0.4 # Get model model = model_lib.mlp_00(th) # Load data train_set, val_set, test_set = load_wiener_hammerstein( th.data_dir, depth=th.memory_depth) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train or evaluate if th.train: model.nn.train(train_set, validation_set=val_set, trainer_hub=th) else: console.show_status('Evaluating ...') model.evaluate(train_set, start_at=th.memory_depth) model.evaluate(val_set, start_at=th.memory_depth) model.evaluate(test_set, start_at=th.memory_depth, plot=True) # End console.end()
def main(_): console.start('trainer.task') # Set default flags FLAGS.train = True if FLAGS.use_default: FLAGS.overwrite = True FLAGS.smart_train = False FLAGS.save_best = False FLAGS.smart_train = True FLAGS.save_best = False WH_PATH = FLAGS.data_dir MARK = 'lottery02' MEMORY_DEPTH = 80 PRINT_CYCLE = 50 EPOCH = 1000 LR = 0.000088 LAYER_DIM = MEMORY_DEPTH * FLAGS.coe # ACTIVATION = FLAGS.activation ACTIVATION = 'relu' # BRANCHES = FLAGS.branches BRANCHES = 6 LR_LIST = [FLAGS.lr1] * (BRANCHES + 1) FLAGS.smart_train = True # Get model model = model_lib.mlp02(MARK, MEMORY_DEPTH, BRANCHES, LAYER_DIM, LR, ACTIVATION, identity_init=True) # Load data set train_set, val_set, test_set = load_wiener_hammerstein(WH_PATH, depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train if FLAGS.train: model.identify(train_set, val_set, batch_size=64, print_cycle=PRINT_CYCLE, epoch=EPOCH, lr_list=LR_LIST) console.end()
def main(_): console.start('vanilla_mlp') # Configurations MARK = 'mlp_vanilla_00' MEMORY_DEPTH = 30 coe = 8 HIDDEN_DIM = MEMORY_DEPTH * coe EPOCH = 5000 LR = 0.000088 BATCH_SIZE = 32 PRINT_CYCLE = 10 ACTIVATION = 'relu' FLAGS.train = True FLAGS.overwrite = True FLAGS.smart_train = True FLAGS.save_best = False FLAGS.summary = True # FLAGS.save_model = False FLAGS.snapshot = False FLAGS.epoch_tol = 100 # Load data train_set, val_set, test_set = generate_data() assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Get model model = lott_lib.mlp00(MARK, MEMORY_DEPTH, HIDDEN_DIM, LR, ACTIVATION) # model.nn._branches_variables_assign(BRANCH_INDEX) # Train or evaluate if FLAGS.train: model.identify(train_set, val_set, batch_size=BATCH_SIZE, print_cycle=PRINT_CYCLE, epoch=EPOCH) else: model.evaluate(train_set, start_at=MEMORY_DEPTH) model.evaluate(val_set, start_at=MEMORY_DEPTH) model.evaluate(test_set, start_at=MEMORY_DEPTH, plot=True) console.end()
def main(_): console.start('trainer.task') # Set default flags if FLAGS.use_default: FLAGS.train = True FLAGS.overwrite = True FLAGS.smart_train = False FLAGS.save_best = False FLAGS.progress_bar = False if FLAGS.data_dir == "": WH_PATH = os.path.join(nls_root, 'data/wiener_hammerstein/whb.tfd') else: WH_PATH = FLAGS.data_dir MARK = 'mlp00' MEMORY_DEPTH = 40 PRINT_CYCLE = 100 EPOCH = 2 LAYER_DIM = MEMORY_DEPTH * 2 LAYER_NUM = 2 LEARNING_RATE = 0.001 BATCH_SIZE = 64 # Get model model = model_lib.mlp_00(MARK, MEMORY_DEPTH, LAYER_DIM, LAYER_NUM, LEARNING_RATE) # Load data set train_set, val_set, test_set = load_wiener_hammerstein(WH_PATH, depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train or evaluate if FLAGS.train: model.identify(train_set, val_set, batch_size=BATCH_SIZE, print_cycle=PRINT_CYCLE, epoch=EPOCH) else: pass console.end()
def main(_): console.start('trainer.task') # Set default flags FLAGS.train = True if FLAGS.use_default: FLAGS.overwrite = True FLAGS.smart_train = False FLAGS.save_best = False FLAGS.smart_train = True FLAGS.save_best = True WH_PATH = FLAGS.data_dir MARK = 'svn00' MEMORY_DEPTH = FLAGS.memory PRINT_CYCLE = 50 EPOCH = 100 LAYER_DIM = MEMORY_DEPTH * 2 LEARNING_RATE = FLAGS.lr BATCH_SIZE = 64 ORDER1 = FLAGS.order1 ORDER2 = FLAGS.order2 ORDER3 = FLAGS.order3 # Get model model = model_lib.svn_00(MEMORY_DEPTH, MARK, LAYER_DIM, ORDER1, ORDER2, ORDER3, LEARNING_RATE) # Load data set train_set, val_set, test_set = load_wiener_hammerstein(WH_PATH, depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train if FLAGS.train: model.identify(train_set, val_set, batch_size=BATCH_SIZE, print_cycle=PRINT_CYCLE, epoch=EPOCH) console.end()
def main(_): # ============================================================================= # Global configuration WH_PATH = './data/wiener_hammerstein/whb.tfd' NN_LEARNING_RATE = 0.001 BATCH_SIZE = 32 MEMORY_DEPTH = 40 NN_EPOCH = 5 PRINT_CYCLE = 100 FLAGS.train = True # FLAGS.train = False FLAGS.overwrite = True # FLAGS.overwrite = False FLAGS.save_best = False # FLAGS.save_best = True FLAGS.smart_train = False FLAGS.epoch_tol = 20 # Turn off overwrite while in save best mode FLAGS.overwrite = FLAGS.overwrite and not FLAGS.save_best and FLAGS.train # ============================================================================= console.start('NN Demo') # Load data set train_set, val_set, test_set = load_wiener_hammerstein(WH_PATH, depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) model = nn_models.mlp_00(NN_LEARNING_RATE, MEMORY_DEPTH) # Define model and identify if FLAGS.train: model.identify(train_set, val_set, batch_size=BATCH_SIZE, print_cycle=PRINT_CYCLE, epoch=NN_EPOCH) console.end()
def main(_): console.start('trainer.task') # Set default flags FLAGS.train = True if FLAGS.use_default: FLAGS.overwrite = True FLAGS.smart_train = False FLAGS.save_best = False FLAGS.smart_train = True FLAGS.save_best = True WH_PATH = FLAGS.data_dir MARK = 'resnet01' MEMORY_DEPTH = 80 PRINT_CYCLE = 50 EPOCH = 100 NN_BLOCKS = FLAGS.blocks order1 = FLAGS.order1 order2 = FLAGS.order2 LAYER_DIM = MEMORY_DEPTH * FLAGS.coe LEARNING_RATE = FLAGS.lr ACTIVATION = FLAGS.activation # Get model model = model_lib.res_00(memory=MEMORY_DEPTH, blocks=NN_BLOCKS, order1=order1, order2=order2, activation=ACTIVATION, learning_rate=LEARNING_RATE) # Load data set train_set, val_set, test_set = load_wiener_hammerstein( WH_PATH, depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train if FLAGS.train: model.identify(train_set, val_set, batch_size=64, print_cycle=PRINT_CYCLE, epoch=EPOCH) console.end()
def main(_): console.start('trainer.task') # Set default flags FLAGS.train = True if FLAGS.use_default: FLAGS.overwrite = True FLAGS.smart_train = False FLAGS.save_best = False WH_PATH = FLAGS.data_dir FLAGS.smart_train = True FLAGS.save_best = True MARK = 'mlp00' MEMORY_DEPTH = 80 PRINT_CYCLE = 50 EPOCH = 300 LAYER_DIM = MEMORY_DEPTH * FLAGS.coe LAYER_NUM = FLAGS.layer_num LEARNING_RATE = FLAGS.lr BATCH_SIZE = 32 ACTIVATION = FLAGS.activation # Get model model = model_lib.mlp_00(MARK, MEMORY_DEPTH, LAYER_DIM, LAYER_NUM, LEARNING_RATE, ACTIVATION) # Load data set train_set, val_set, test_set = load_wiener_hammerstein(WH_PATH, depth=MEMORY_DEPTH) assert isinstance(train_set, DataSet) assert isinstance(val_set, DataSet) assert isinstance(test_set, DataSet) # Train if FLAGS.train: model.identify(train_set, val_set, batch_size=BATCH_SIZE, print_cycle=PRINT_CYCLE, epoch=EPOCH) console.end()
def activate(export_false=False): assert callable(th.model) model = th.model(th) assert isinstance(model, Classifier) # Load data train_set, val_set, test_set = load_data(th.data_dir) # Train or evaluate if th.train: model.train(train_set, validation_set=val_set, trainer_hub=th) else: model.evaluate_model(train_set) model.evaluate_model(val_set) model.evaluate_model(test_set, export_false=export_false) # End console.end()
def activate(): assert callable(th.model) model = th.model(th) assert isinstance(model, Predictor) # Load data train_set, val_set, _ = du.load(th.data_dir, th.sequence_length, th.fixed_length, th.val_size) th.record_gap = th.terminal_threshold / 10 # Train model.train(train_set, validation_set=val_set, trainer_hub=th, terminator=lambda metric: metric < th.terminal_threshold) # End model.shutdown() console.end()