示例#1
0
    [tf.sparse_placeholder(tf.float32)
     for _ in range(num_supports)],  # graph structure in the third block
    'faces':
    [tf.placeholder(tf.int32, shape=(None, 4))
     for _ in range(num_blocks)],  # helper for face loss (not used)
    'edges':
    [tf.placeholder(tf.int32, shape=(None, 2))
     for _ in range(num_blocks)],  # helper for normal loss
    'lape_idx':
    [tf.placeholder(tf.int32, shape=(None, 10))
     for _ in range(num_blocks)],  # helper for laplacian regularization
    'pool_idx':
    [tf.placeholder(tf.int32, shape=(None, 2))
     for _ in range(num_blocks - 1)]  # helper for graph unpooling
}
model = GCN(placeholders, logging=True)


def f_score(label, predict, dist_label, dist_pred, threshold):
    num_label = label.shape[0]
    num_predict = predict.shape[0]

    f_scores = []
    for i in range(len(threshold)):
        num = len(np.where(dist_label <= threshold[i])[0])
        recall = 100.0 * num / num_label
        num = len(np.where(dist_pred <= threshold[i])[0])
        precision = 100.0 * num / num_predict

        f_scores.append((2 * precision * recall) / (precision + recall + 1e-8))
    return np.array(f_scores)
示例#2
0
# Define placeholders(dict) and model
num_blocks = 3
num_supports = 2
placeholders = {
    'features': tf.placeholder(tf.float32, shape=(None, 3)),
    'img_inp': tf.placeholder(tf.float32, shape=(224, 224, 3)),
    'labels': tf.placeholder(tf.float32, shape=(None, 6)),
    'support1': [tf.sparse_placeholder(tf.float32) for _ in range(num_supports)],
    'support2': [tf.sparse_placeholder(tf.float32) for _ in range(num_supports)],
    'support3': [tf.sparse_placeholder(tf.float32) for _ in range(num_supports)],
    'faces': [tf.placeholder(tf.int32, shape=(None, 4)) for _ in range(num_blocks)],  #for face loss, not used.
    'edges': [tf.placeholder(tf.int32, shape=(None, 2)) for _ in range(num_blocks)], 
    'lape_idx': [tf.placeholder(tf.int32, shape=(None, 10)) for _ in range(num_blocks)], #for laplace term
    'pool_idx': [tf.placeholder(tf.int32, shape=(None, 2)) for _ in range(num_blocks-1)] #for unpooling
}
model = GCN(placeholders, logging=True)

# Load data, initialize session
data = DataFetcher(FLAGS.data_list)
data.setDaemon(True) ####
data.start()
config=tf.ConfigProto()
#config.gpu_options.allow_growth=True
config.allow_soft_placement=True
sess = tf.Session(config=config)
sess.run(tf.global_variables_initializer())
#model.load(sess)

# Train graph model
train_loss = open('record_train_loss.txt', 'a')
train_loss.write('Start training, lr =  %f\n'%(FLAGS.learning_rate))