Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # In[118]:
- def inception(i, num_layers, w, stride):
- c = tf.layers.conv2d(
- inputs=i,
- filters=num_layers,
- kernel_size=(w, 1),
- padding='same',
- use_bias=False
- )
- c = tf.layers.conv2d(
- inputs=c,
- filters=num_layers,
- kernel_size=(1, w),
- padding='same',
- use_bias=False
- )
- bias = tf.Variable(tf.zeros([num_layers]))
- c = tf.nn.bias_add(c, bias)
- c = tf.nn.relu(c)
- return c
- # In[140]:
- tf.reset_default_graph()
- sess = tf.InteractiveSession()
- x = tf.placeholder(tf.float32, shape=(None, None, None, 3))
- y = tf.placeholder(tf.float32, shape=(None, None, None, 1))
- c = inception(x, 64, 5)
- for _ in range(16):
- c = tf.concat([
- inception(c, 16, 7),
- inception(c, 16, 5),
- inception(c, 32, 3),
- ], 3)
- o = tf.layers.conv2d(c, 1, (1, 1), activation=tf.nn.sigmoid)
- y_flat = tf.layers.flatten(y)
- o_flat = tf.layers.flatten(o)
- loss_op = tf.reduce_mean(tf.keras.backend.binary_crossentropy(y_flat, o_flat), 1)
- train_op = tf.train.AdamOptimizer(1e-4).minimize(loss_op)
- iou_op = mean_iou(y_flat, o_flat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement