【问题标题】:Best practices to use .tfrecord files for forecasting使用 .tfrecord 文件进行预测的最佳实践
【发布时间】:2020-10-20 14:48:17
【问题描述】:

在 TFRecord 文件中存储/读取数据以训练预测模型的最佳做法是什么?我想建立一个模型,该模型可以根据其历史健康数据(例如,来自一组电机的历史数据,包括每个电机的速度、错误率、故障、等)。

我可以使用 Apache Beam/Dataflow 进行整个预处理(标准化数据、估算缺失值、设计新功能、拆分以训练/验证/测试集等)。但我在想也许最好将原始数据存储为 .tfrecord 文件并使用 TFX 进行标准化、插补等,以使实验更容易。 TFX tensorflow_transform currently doesn't support tf.SequenceExample files。因此,我正在考虑将原始数据存储为 tf.Example 文件,每条记录的格式如下:

example_proto = tf.train.Example(features=tf.train.Features(feature={
    'timestamp': tf.train.Feature(int64_list=tf.train.Int64List(
        value=[1601200000, 1601200060, 1601200120, ...])),
    'feature0': tf.train.Feature(float_list=tf.train.FloatList(
        value=[np.nan, 15523.0, np.nan, ...])),
    'feature1': tf.train.Feature(float_list=tf.train.FloatList(
        value=[1.0, -8.0, np.nan, ...])),
    ...
    'label': tf.train.Feature(float_list=tf.train.FloatList(
        value=[0.5, -10.3, 2.1, ...])),
}))

你怎么看?有什么建议吗?

【问题讨论】:

    标签: tensorflow apache-beam tensorflow-datasets tfrecord tfx


    【解决方案1】:

    TFX 0.23.0 在某些组件中添加了对 TF.ExampleSequence 的支持。

    您还可以按照您描述的方式使用列表来使用 TF.Example。如果您需要根据 TF.Example 向模型提供序列,则需要使用 TF.transform 来堆叠和重塑读入的值。

    float32 = tf.reshape(
            tf.stack(...),
            [-1, timesteps, features)])
    

    【讨论】:

      猜你喜欢
      • 2010-11-16
      • 1970-01-01
      • 2010-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多