Exemplo n.º 1
0
    session_conf.gpu_options.allow_growth = True
    #    sess = tf.Session(config=session_conf)
    sess = tf.InteractiveSession()

    model = models.setup(params)
    model.build_graph()
    saver = tf.train.Saver()

    sess.run(tf.global_variables_initializer())
    for i in range(params.epochs):

        for data in reader.getTrain(
                overlap_feature=False):  #model=model,sess=sess,
            #        for data in data_helper.getBatch48008(train,alphabet,args.batch_size):
            _, summary, step, loss, accuracy, score12, score13, see = model.train(
                sess, data)
            time_str = datetime.datetime.now().isoformat()
            print(
                "{}: step {}, loss {:g}, acc {:g} ,positive {:g},negative {:g}"
                .format(time_str, step, loss, accuracy, np.mean(score12),
                        np.mean(score13)))
#            logger.info("{}: step {}, loss {:g}, acc {:g} ,positive {:g},negative {:g}".format(time_str, step, loss, accuracy,np.mean(score12),np.mean(score13)))

        test_datas = reader.getTest()
        predicted_test = predict(model, sess, test_datas, reader.datas["test"])
        map_mrr_test = evaluation.evaluationBypandas(reader.datas["test"],
                                                     predicted_test)

        #        logger.info('map_mrr test' +str(map_mrr_test))
        print('epoch ' + str(i) + ' map_mrr test' + str(map_mrr_test))
Exemplo n.º 2
0
 def evaluate(self, predicted, mode="test", acc=False):
     return evaluation.evaluationBypandas(self.datas[mode],
                                          predicted,
                                          acc=acc)