Beispiel #1
0
MAX_OUTPUT_LENGTH = 20

pd.set_option('display.width', 10000)

parser = argparse.ArgumentParser(description='')
parser.add_argument('--gpu', type=int, default=None)
parser.add_argument('--dataset_path', type=str)
parser.add_argument('--model_path', type=str)
args = parser.parse_args()

model_path = '../result/models/epoch3/model.ckpt'
dataset_path = '../data/dataset/train.csv' #################################### test.csv

dictionary_path = '../data/dataset/dictionary.pkl'
token2id = dataset.load_dictionary(dictionary_path)
id2token = {i:t for t, i in token2id.items()}

symbol_ids = {'<S>': token2id['<S>'], '<EOS>': token2id['<EOS>']}
vocab_size = len(list(token2id.keys()))
config.params.vocab_size = vocab_size

dataset = dataset.str2list(dataset.load_dataset(dataset_path, 1, 100))

sess = tf.Session()
if args.gpu:
    with tf.device('/gpu:%d'%args.gpu):
        model = ABSmodel(config.params)
        model.rebuild_forward_graph(sess, model_path)
else:
    model = ABSmodel(config.params)
Beispiel #2
0
    parser.add_argument('--test_phase', type=bool, default=False)
    args = parser.parse_args()
    return args


if __name__ == '__main__':
    args = parse_args()
    torch.backends.cudnn.enabled = False
    torch.manual_seed(args.seed)
    torch.cuda.manual_seed(args.seed)
    torch.backends.cudnn.benchmark = True
    print('parameters:', args)
    print('task:', args.task, 'model:', args.model)

    # dictionary = Dictionary.load_from_file('./dictionary.pkl')
    dictionary = load_dictionary(args.sentense_file_path, args.task)

    train_dset = VQAFeatureDataset(args,
                                   dictionary,
                                   args.sentense_file_path,
                                   args.feat_category,
                                   args.feat_path,
                                   mode='Train')
    # val_dset = VQAFeatureDataset(args, dictionary, args.sentense_file_path,args.feat_category,args.feat_path, mode='Valid')
    eval_dset = VQAFeatureDataset(args,
                                  dictionary,
                                  args.sentense_file_path,
                                  args.feat_category,
                                  args.feat_path,
                                  mode='Test')
    batch_size = args.batch_size
Beispiel #3
0
import dataset
from nets import simpleNet
from ma import movingAverage


from sklearn.metrics import classification_report
y_true = []
y_pred = []

def monitorMA(example, movingAverage):
	if example not in monitor:
		monitor[example] = list()
	else:
		monitor[example].append(movingAverage)

data = dataset.load_dictionary()

nn = simpleNet(architecture=numpy.array([15 , data.shape[0]]))

success_rate = dict()
monitor = dict()

for epoch in tqdm(range(50000)):
	for example in range(data.shape[0]):

		input = data[example][1]
		target = data[example][0]
		y_true.append(target)

		output = nn.forward(input)
		y_pred.append(output)