def test(args): [theta, bias] = pickle.load(open(args.model_file)) nnet = FFNeuralNetwork() nnet.set_activation_func(args.actv) nnet.set_output_func('softmax') nnet.initialize(theta, bias) data = pickle.load(open(args.test_file)) print 'Error :',nnet.test(data['X'], data['Y'])
def train(args): tr_data = pickle.load(open(args.train_file)) vd_data = pickle.load(open(args.validation_file)) [theta, bias] = pickle.load(open(args.init_wt_file)) perf_db = DatabaseAccessor(Perf, args.model_perf_db) perf_db.create_table() debug_db = DatabaseAccessor(Distribution, args.debug_db) debug_db.create_table() nnet = FFNeuralNetwork() nnet.set_activation_func(args.actv) nnet.set_output_func('softmax') nnet.initialize(theta, bias) if args.train_layers: nnet.set_train_layers(args.train_layers) nnet.set_perf_writer(perf_db) nnet.set_debug_writer(debug_db) btheta, bbias = nnet.train(tr_data['X'], tr_data['Y'], vd_data['X'], vd_data['Y'], args.mini_batch_size, args.epochs, args.validation_freq) pickle.dump([btheta,bbias], open(args.model_file, 'wb'))