Esempio n. 1
0
    # Output Map
    weight = weight_variable([1, 1, features, 1], stddev)
    bias = bias_variable([1], -0.5)
    conv = conv2d(in_node, weight, tf.constant(1.0))
    pred_mask = tf.nn.sigmoid(conv + bias)
    #pred_mask = tf.nn.relu(conv + bias)

    # loss

    #loss = tf.losses.mean_squared_error(pred_mask, crop(s_img,pred_mask))
    #loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=s_, labels=s))
    #loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=s_, labels=s))

    loss = tf.reduce_mean(
        tf.nn.sigmoid_cross_entropy_with_logits(
            logits=conv + bias, labels=crop(s_img, pred_mask)))  #sigmoid
    #loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=pred_mask, labels=crop(s_img,pred_mask))) #relu
    loss_sum = tf.summary.scalar("cross_entropy_early", loss)

    loss_batch = tf.placeholder(tf.float32)
    loss_batch_summary = tf.summary.scalar("cross_entropy_early", loss_batch)

    #accuracy

    #correct_prediction = tf.equal(tf.round(tf.clip_by_value(pred_mask, 0., 1.),),crop(s_img,pred_mask)) # relu
    correct_prediction = tf.equal(tf.round(pred_mask, ),
                                  crop(s_img, pred_mask))  # sigmoid
    accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float64))
    accuracy_sum = tf.summary.scalar("accuracy_early", accuracy)

    accuracy_batch = tf.placeholder(tf.float32)
Esempio n. 2
0
        convs.append((conv1, conv2))

    # Output Map
    weight = weight_variable([1, 1, features_root, 1], stddev)
    bias = bias_variable([1], -0.5)
    conv = conv2d(in_node, weight, tf.constant(1.0))
    pred_mask = tf.nn.sigmoid(conv + bias)

    # loss

    #loss = tf.losses.mean_squared_error(pred_mask, crop(s_img,pred_mask))
    #loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=s_, labels=s))
    #loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=s_, labels=s))
    loss = tf.reduce_mean(
        tf.nn.sigmoid_cross_entropy_with_logits(
            logits=conv + bias, labels=crop(s_img, pred_mask)))  #sigmoid
    #loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits=pred_mask, labels=crop(s_img,pred_mask))) #relu
    loss_sum = tf.summary.scalar("cross_entropy_unet", loss)

    loss_batch = tf.placeholder(tf.float32)
    loss_batch_summary = tf.summary.scalar("cross_entropy_unet", loss_batch)

    #accuracy

    #correct_prediction = tf.equal(tf.round(tf.clip_by_value(pred_mask, 0., 1.),),crop(s_img,pred_mask)) # relu
    correct_prediction = tf.equal(tf.round(pred_mask), crop(s_img, pred_mask))
    accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float64))
    accuracy_sum = tf.summary.scalar("accuracy_unet", accuracy)

    accuracy_batch = tf.placeholder(tf.float32)
    accuracy_batch_summary = tf.summary.scalar("accuracy_unet", accuracy_batch)