rdwords.sort(key = lambda x : x[1], reverse = True) outcnt = 0 for i in range(len(rdwords)): if owords[rdwords[i][0]] > 20: print(rdwords[i], owords[rdwords[i][0]]) outcnt += 1 if outcnt > 20: break; avelenth = float(total_lenth) / float(len(test_data)) avedis = float(total_dis) / float(len(test_data)) #print "average length", avelenth #print "average distilled length", avedis return float(acc) / len(test_data) config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config = config) as sess: #model critic = LSTM_CriticNetwork(sess, args.dim, args.optimizer, args.lr, args.tau, args.grained, args.maxlenth, args.dropout, word_vector) actor = ActorNetwork(sess, args.dim, args.optimizer, args.lr, args.tau) #print variables for item in tf.trainable_variables(): print (item.name, item.get_shape()) saver = tf.train.Saver() saver.restore(sess, "checkpoints/best816") print(test(sess, actor, critic, dev_data))
else: actions, action_pos = sampling_random(lenth, paction) if len(actions) != args.maxlenth: print(inputs) #predict out = critic.predict_target([inputs], [actions], [action_pos], [lenth], [len(action_pos)]) if np.argmax(out) == np.argmax(solution): acc += 1 return float(acc) / len(test_data) config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config = config) as sess: #model critic = LSTM_CriticNetwork(sess, args.dim, args.optimizer, args.lr, args.tau, args.grained, args.attention, args.maxlenth, args.dropout, word_vector) actor = ActorNetwork(sess, args.dim, args.optimizer, args.lr, args.tau, critic.get_num_trainable_vars()) state_size = critic.state_size #print variables for item in tf.trainable_variables(): print((item.name, item.get_shape())) saver = tf.train.Saver() #LSTM pretrain if args.RLpretrain != '': pass elif args.LSTMpretrain == '': sess.run(tf.global_variables_initializer()) for i in range(0,2):