Spec-Zone.ru › TensorFlow 2.9

tf.train.Features

Просмотреть исходный код на GitHub

Используется в tf.train.Example протоколах. Содержит отображение ключей на Feature.

Просмотр псевдонимов

Псевдонимы для миграции

См. Руководство по миграции для получения дополнительных сведений.

tf.compat.v1.train.Features

Протокол Example представляет собой представление следующего типа Python:

Dict[str,
     Union[List[bytes],
           List[int64],
           List[float]]]

Этот протокол реализует Dict.

int_feature = tf.train.Feature(
    int64_list=tf.train.Int64List(value=[1, 2, 3, 4]))
float_feature = tf.train.Feature(
    float_list=tf.train.FloatList(value=[1., 2., 3., 4.]))
bytes_feature = tf.train.Feature(
    bytes_list=tf.train.BytesList(value=[b"abc", b"1234"]))

example = tf.train.Example(
    features=tf.train.Features(feature={
        'my_ints': int_feature,
        'my_floats': float_feature,
        'my_bytes': bytes_feature,
    }))

Используйте tf.io.parse_example, чтобы извлечь тензоры из сериализованного протокола Example:

tf.io.parse_example(
    example.SerializeToString(),
    features = {
        'my_ints': tf.io.RaggedFeature(dtype=tf.int64),
        'my_floats': tf.io.RaggedFeature(dtype=tf.float32),
        'my_bytes': tf.io.RaggedFeature(dtype=tf.string)})
{'my_bytes': <tf.Tensor: shape=(2,), dtype=string,
                         numpy=array([b'abc', b'1234'], dtype=object)>,
 'my_floats': <tf.Tensor: shape=(4,), dtype=float32,
                          numpy=array([1., 2., 3., 4.], dtype=float32)>,
 'my_ints': <tf.Tensor: shape=(4,), dtype=int64,
                        numpy=array([1, 2, 3, 4])>}
Атрибуты
feature repeated FeatureEntry feature

Дочерние классы

class FeatureEntry

© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.9/api_docs/python/tf/train/Features

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API