parser.add_argument('--X_train_train_npy', default='data/X_train_train') parser.add_argument('--X_train_test_npy', default='data/X_train_test') parser.add_argument('--y_train_train_npy', default='data/y_train_train') parser.add_argument('--y_train_test_npy', default='data/y_train_test') parser.add_argument('--hw', default=48, type=int) parser.add_argument('--out_dir', default='models/') args = parser.parse_args() if __name__ == '__main__': print('Loading training images') X_train, X_test = np.load('%s_%i.npy' % (args.X_train_train_npy, args.hw)), np.load('%s_%i.npy' % (args.X_train_test_npy, args.hw)) y_train, y_test = np.load('%s_%i.npy' % (args.y_train_train_npy, args.hw)), np.load('%s_%i.npy' % (args.y_train_test_npy, args.hw)) print(X_train.shape, X_test.shape, y_train.shape, y_test.shape) print('Loading base net from %s' % args.base_net_fname) base_net = utils.load_from_pickle(args.base_net_fname) print('Loading model definition from %s' % args.net_name) net = get_net(args.net_name) net.load_weights_from(base_net) t0 = time() print('Started training at %s' % t0) net.fit(X_train, y_train) print('Finished training. Took %i seconds' % (time() - t0)) y_test_pred = net.predict(X_test) y_test_pred_proba = net.predict_proba(X_test) lscore = utils.multiclass_log_loss(y_test, y_test_pred_proba) ascore = net.score(X_test, y_test)
parser.add_argument('--translate_y_upper', default=-2, type=int) parser.add_argument('--translate_y_step', default=3, type=int) parser.add_argument('--translate_x_lower', default=2, type=int) parser.add_argument('--translate_x_upper', default=-2, type=int) parser.add_argument('--translate_x_step', default=3, type=int) args = parser.parse_args() if __name__ == '__main__': print('Loading test images from %s' % (args.X_train_npy)) X = np.load(args.X_train_npy) hw = args.hw print('Loading model from %s' % args.model) net = utils.load_from_pickle(args.model) # if 'mean' not in net.batch_iterator_test: # print('Warning: net.batch_iterator_test does not have preset mean value. Using mean from all training data for now') net.batch_iterator_test.mean = np.mean(X, axis=0) scale_choices = np.linspace(args.scale_lower, args.scale_upper, args.scale_step) rotation_choices = range(args.rotation_lower, args.rotation_upper, args.rotation_step) translate_y_choices = range(args.translate_y_lower, args.translate_y_upper, args.translate_y_step) translate_x_choices = range(args.translate_x_lower, args.translate_x_upper, args.translate_x_step) combinations = list( itertools.product(scale_choices, rotation_choices, translate_y_choices,