Exemplo n.º 1
0
def init_imgnetwork(pc_trans_feat):
    step = tf.Variable(0)

    with tf.variable_scope("img_var"):
        img_placeholder = tf.placeholder(
            tf.float32, shape=[FEAT_BARCH_SIZE * BATCH_DATA_SIZE, 256, 256, 3])
        img_feat, _ = resnet.endpoints(img_placeholder, None, is_training=True)

    img_feat = tf.reshape(
        img_feat, [FEAT_BARCH_SIZE, BATCH_DATA_SIZE, img_feat.shape[1]])
    q_img_vec, pos_img_vec, neg_img_vec, oth_img_vec = tf.split(
        img_feat, [1, POS_NUM, NEG_NUM, OTH_NUM], 1)
    img_loss = lazy_quadruplet_loss(q_img_vec, pos_img_vec, neg_img_vec,
                                    oth_img_vec, MARGIN1, MARGIN2)
    tf.summary.scalar('img_loss', img_loss)

    epoch_num_placeholder = tf.placeholder(tf.float32, shape=())
    learning_rate = get_learning_rate(epoch_num_placeholder)
    tf.summary.scalar('learning_rate', learning_rate)
    optimizer = tf.train.AdamOptimizer(learning_rate)
    img_train_op = optimizer.minimize(img_loss, global_step=step)
    merged = tf.summary.merge_all()

    ops = {
        "img_placeholder": img_placeholder,
        "epoch_num_placeholder": epoch_num_placeholder,
        "img_loss": img_loss,
        "img_train_op": img_train_op,
        "merged": merged,
        "step": step
    }
    return ops
def init_imgnetwork(pc_trans_feat):
    with tf.variable_scope("img_var"):
        img_placeholder = tf.placeholder(tf.float32,
                                         shape=[BATCH_SIZE, 240, 320, 3])
        img_feat, img_pc_feat = resnet.endpoints(img_placeholder,
                                                 pc_trans_feat,
                                                 is_training=False)
    return img_placeholder, img_feat, img_pc_feat
def init_imgnetwork(pc_trans_feat):
    with tf.variable_scope("img_var"):
        img_placeholder = tf.placeholder(
            tf.float32, shape=[FEAT_BARCH_SIZE * BATCH_DATA_SIZE, 256, 256, 3])
        img_feat, img_pc_feat = resnet.endpoints(img_placeholder,
                                                 pc_trans_feat,
                                                 is_training=True)
    return img_placeholder, img_feat, img_pc_feat