Пример #1
0
def image_module_fn():
    images = tf_v1.placeholder(dtype=tf.float32, shape=[None, 2, 4, 3])
    sum_by_channels = tf.reduce_sum(images, [1, 2])
    sum_all = tf.reduce_sum(images, [1, 2, 3])
    native_module.add_signature(inputs=dict(images=images),
                                outputs=dict(default=sum_all,
                                             sum_by_channels=sum_by_channels))
Пример #2
0
def image_module_fn():
  images = tf.placeholder(dtype=tf.float32, shape=[None, 2, 4, 3])
  sum_by_channels = tf.reduce_sum(images, [1, 2])
  sum_all = tf.reduce_sum(images, [1, 2, 3])
  native_module.add_signature(inputs=dict(images=images),
                              outputs=dict(default=sum_all,
                                           sum_by_channels=sum_by_channels))
Пример #3
0
def image_module_fn_with_info():
    images = tf_v1.placeholder(dtype=tf.float32, shape=[None, None, None, 3])
    sum_all = tf.reduce_sum(images, [1, 2, 3])
    native_module.add_signature(inputs=dict(images=images),
                                outputs=dict(default=sum_all))
    image_module_info = image_util.ImageModuleInfo()
    size = image_module_info.default_image_size
    size.height, size.width = 2, 4
    image_util.attach_image_module_info(image_module_info)
Пример #4
0
def batch_norm_module(training):
  x = tf.placeholder(tf.float32, shape=[None, 3])
  y = tf.layers.batch_normalization(x, training=training)
  native_module.add_signature(inputs=x, outputs=y)
Пример #5
0
def multi_signature_module():
  x = tf.placeholder(tf.float32, shape=[None])
  native_module.add_signature("double", {"x": x}, {"y": 2*x})

  z = tf.placeholder(tf.float32, shape=[None])
  native_module.add_signature("square", {"z": z}, {"z_out": z*z})