tf_upgrade_v2 for network/classification/lmnet_v0.py
@@ -53,7 +53,7 @@ class LmnetV0(Base):
channels_data_format = 'channels_last' if self.data_format == 'NHWC' else 'channels_first'
_lmnet_block = self._get_lmnet_block(is_training, channels_data_format)
- _max_pooling2d = functools.partial(tf.layers.max_pooling2d, pool_size=2, strides=2, padding='SAME',
+ _max_pooling2d = functools.partial(tf.compat.v1.layers.max_pooling2d, pool_size=2, strides=2, padding='SAME',
data_format=channels_data_format)
self.images = images
@@ -70,10 +70,10 @@ class LmnetV0(Base):
x = _max_pooling2d(name='pool5', inputs=x)
x = _lmnet_block('conv6', x, 64, 1, activation=tf.nn.relu)
- x = tf.layers.dropout(x, training=is_training)
+ x = tf.compat.v1.layers.dropout(x, training=is_training)
- kernel_initializer = tf.random_normal_initializer(mean=0.0, stddev=0.01)
- x = tf.layers.conv2d(name='conv7',
+ kernel_initializer = tf.compat.v1.random_normal_initializer(mean=0.0, stddev=0.01)
+ x = tf.compat.v1.layers.conv2d(name='conv7',
inputs=x,
filters=self.num_classes,
kernel_size=1,
@@ -86,7 +86,7 @@ class LmnetV0(Base):
h = x.get_shape()[1].value if self.data_format == 'NHWC' else x.get_shape()[2].value
w = x.get_shape()[2].value if self.data_format == 'NHWC' else x.get_shape()[3].value
- x = tf.layers.average_pooling2d(name='pool7',
+ x = tf.compat.v1.layers.average_pooling2d(name='pool7',
inputs=x,
pool_size=[h, w],
padding='VALID',
