当前位置: 首页>>代码示例>>Python>>正文


Python feature_pb2.Feature方法代码示例

本文整理汇总了Python中tensorflow.core.example.feature_pb2.Feature方法的典型用法代码示例。如果您正苦于以下问题:Python feature_pb2.Feature方法的具体用法?Python feature_pb2.Feature怎么用?Python feature_pb2.Feature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.core.example.feature_pb2的用法示例。


在下文中一共展示了feature_pb2.Feature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _write_test_data

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _write_test_data():
        schema = feature_spec_to_schema({"f0": tf.VarLenFeature(dtype=tf.int64),
                                         "f1": tf.VarLenFeature(dtype=tf.int64),
                                         "f2": tf.VarLenFeature(dtype=tf.int64)})
        batches = [
            [1, 4, None],
            [2, None, None],
            [3, 5, None],
            [None, None, None],
        ]

        example_proto = [example_pb2.Example(features=feature_pb2.Features(feature={
            "f" + str(i): feature_pb2.Feature(int64_list=feature_pb2.Int64List(value=[f]))
            for i, f in enumerate(batch) if f is not None
        })) for batch in batches]

        return DataUtil.write_test_data(example_proto, schema) 
开发者ID:spotify,项目名称:spotify-tensorflow,代码行数:19,代码来源:dataset_test.py

示例2: create_tf_record

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def create_tf_record(self):
    path = os.path.join(self.get_temp_dir(), 'tfrecord')
    writer = tf.python_io.TFRecordWriter(path)

    image_tensor = np.random.randint(255, size=(4, 5, 3)).astype(np.uint8)
    with self.test_session():
      encoded_jpeg = tf.image.encode_jpeg(tf.constant(image_tensor)).eval()
    example = example_pb2.Example(features=feature_pb2.Features(feature={
        'image/encoded': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=[encoded_jpeg])),
        'image/format': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=['jpeg'.encode('utf-8')])),
        'image/transcript': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=[
                'hello'.encode('utf-8')]))
    }))
    writer.write(example.SerializeToString())
    writer.close()

    return path 
开发者ID:bgshih,项目名称:aster,代码行数:22,代码来源:input_reader_builder_test.py

示例3: create_tf_record

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def create_tf_record(self):
    path = os.path.join(self.get_temp_dir(), 'tfrecord')
    writer = tf.python_io.TFRecordWriter(path)

    image_tensor = np.random.randint(255, size=(4, 5, 3)).astype(np.uint8)
    with self.test_session():
      encoded_jpeg = tf.image.encode_jpeg(tf.constant(image_tensor)).eval()
    example = example_pb2.Example(features=feature_pb2.Features(feature={
        'image/encoded': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=[encoded_jpeg])),
        'image/format': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=['jpeg'.encode('utf-8')])),
        'image/object/bbox/xmin': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[0.0])),
        'image/object/bbox/xmax': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[1.0])),
        'image/object/bbox/ymin': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[0.0])),
        'image/object/bbox/ymax': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[1.0])),
        'image/object/class/label': feature_pb2.Feature(
            int64_list=feature_pb2.Int64List(value=[2])),
    }))
    writer.write(example.SerializeToString())
    writer.close()

    return path 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:29,代码来源:input_reader_builder_test.py

示例4: _encoded_int64_feature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _encoded_int64_feature(ndarray):
  return feature_pb2.Feature(int64_list=feature_pb2.Int64List(
      value=ndarray.flatten().tolist())) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:5,代码来源:test_utils.py

示例5: _encoded_bytes_feature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _encoded_bytes_feature(tf_encoded):
  encoded = tf_encoded.eval()

  def string_to_bytes(value):
    return feature_pb2.BytesList(value=[value])

  return feature_pb2.Feature(bytes_list=string_to_bytes(encoded)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:9,代码来源:test_utils.py

示例6: _string_feature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _string_feature(value):
  value = value.encode('utf-8')
  return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=[value])) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:5,代码来源:test_utils.py

示例7: _EncodedFloatFeature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _EncodedFloatFeature(self, ndarray):
    return feature_pb2.Feature(float_list=feature_pb2.FloatList(
        value=ndarray.flatten().tolist())) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:5,代码来源:tfexample_decoder_test.py

示例8: _EncodedInt64Feature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _EncodedInt64Feature(self, ndarray):
    return feature_pb2.Feature(int64_list=feature_pb2.Int64List(
        value=ndarray.flatten().tolist())) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:5,代码来源:tfexample_decoder_test.py

示例9: _EncodedBytesFeature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _EncodedBytesFeature(self, tf_encoded):
    with self.test_session():
      encoded = tf_encoded.eval()

    def BytesList(value):
      return feature_pb2.BytesList(value=[value])

    return feature_pb2.Feature(bytes_list=BytesList(encoded)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:10,代码来源:tfexample_decoder_test.py

示例10: _BytesFeature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _BytesFeature(self, ndarray):
    values = ndarray.flatten().tolist()
    for i in range(len(values)):
      values[i] = values[i].encode('utf-8')
    return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=values)) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:7,代码来源:tfexample_decoder_test.py

示例11: _StringFeature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _StringFeature(self, value):
    value = value.encode('utf-8')
    return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=[value])) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:5,代码来源:tfexample_decoder_test.py

示例12: setUp

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def setUp(self):
    super(ParseBase, self).setUp()
    examples = [
        example_pb2.Example(features=feature_pb2.Features(feature={
            'a':
                feature_pb2.Feature(
                    int64_list=feature_pb2.Int64List(value=[1])),
            'b':
                feature_pb2.Feature(
                    int64_list=feature_pb2.Int64List(value=[2, 3, 4])),
        })),
        example_pb2.Example(features=feature_pb2.Features(feature={
            'a':
                feature_pb2.Feature(
                    int64_list=feature_pb2.Int64List(value=[5])),
            'b':
                feature_pb2.Feature(
                    int64_list=feature_pb2.Int64List(value=[6, 7, 8])),
        })),
    ]
    self.serialized = core.LabeledTensor(
        constant_op.constant([ex.SerializeToString() for ex in examples]),
        ['batch'])
    self.features = {
        'a': io_ops.FixedLenFeature([], dtypes.int64),
        'b': io_ops.FixedLenFeature([('x', 3)], dtypes.int64)
    } 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:29,代码来源:io_ops_test.py

示例13: _Int64Feature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _Int64Feature(self, value):
    return tf.train.Feature(int64_list=tf.train.Int64List(value=value)) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:4,代码来源:tf_example_decoder_test.py

示例14: _FloatFeature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _FloatFeature(self, value):
    return tf.train.Feature(float_list=tf.train.FloatList(value=value)) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:4,代码来源:tf_example_decoder_test.py

示例15: _BytesFeature

# 需要导入模块: from tensorflow.core.example import feature_pb2 [as 别名]
# 或者: from tensorflow.core.example.feature_pb2 import Feature [as 别名]
def _BytesFeature(self, value):
    if isinstance(value, list):
      return tf.train.Feature(bytes_list=tf.train.BytesList(value=value))
    return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value])) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:6,代码来源:tf_example_decoder_test.py


注:本文中的tensorflow.core.example.feature_pb2.Feature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。