Exemple #1
0
    def __init__(self):
        self.total_emb, self.single_size, self.numerical_size, self.multi_size = _get_conf()
        self.field_size = self.single_size + self.numerical_size + self.multi_size
        self.embedding_length = self.field_size * Config.embedding_size
        self._init_data()
        self._init_placeholder()
        self._init_Variable()
        self._init_Model()
        self.valid_batch = self._get_batch(self.valid, -1)
        self.valid_label = get_label(self.valid_batch[0], 2)
        self.valid_dict = {
            self.ph['single_index']: self.valid_batch[1],
            self.ph['numerical_index']: self.valid_batch[2],
            self.ph['numerical_value']: self.valid_batch[3],
            self.ph['value']: self.valid_batch[-1],
            self.ph['label']: self.valid_label,
            self.train_phase: False
        }
        if Config.multi_features:
            for idx, s in enumerate(Config.multi_features):
                self.valid_dict[self.ph['multi_index_%s' % s]] = self.valid_batch[4]
                self.valid_dict[self.ph['multi_value_%s' % s]] = self.valid_batch[5]
        self.global_step = []
        self.global_train_auc = []
        self.global_valid_auc = []

        self._train()
        self._save_loss()
Exemple #2
0
    def __init__(self):
        self.total_emb, self.single_size, self.numerical_size, self.multi_size = _get_conf(
        )
        self.field_size = self.single_size + self.numerical_size + self.multi_size
        self.embedding_length = self.field_size * Config.embedding_size

        self._init_data()
        self._init_placeholder()
        self._init_Variable()
        self._init_Model()

        self._train()
Exemple #3
0
with tf.Session() as sess:
    new_saver = tf.train.import_meta_graph(meta_path)
    new_saver.restore(sess, model_path)
    # init = tf.global_variables_initializer()
    # sess.run(init)

    graph = tf.get_default_graph()
    ph, train_phase = _init_placeholder(graph)
    print(ph)

    prediction = tf.get_collection('pred_network')[0]
    # loss = tf.get_collection('loss')[0]
    loss = graph.get_tensor_by_name('loss:0')

    total_emb, single_size, numerical_size, multi_size = _get_conf()
    field_size = single_size + numerical_size + multi_size
    embedding_length = field_size * Config.embedding_size

    test = _get_data(Config.test_save_file)
    test = test[:30000]
    test_batch = _get_batch(test,
                            -1,
                            single_size=single_size,
                            numerical_size=numerical_size,
                            multi_size=multi_size)
    test_label = get_label(test_batch[0], 2)

    test_dict = {
        ph['single_index']: test_batch[1],
        ph['numerical_index']: test_batch[2],