【问题标题】:How to replace tf.train.batch , as it is deprecated如何替换 tf.train.batch ,因为它已被弃用
【发布时间】:2020-11-01 19:36:10
【问题描述】:

这是使用 Petastorm 训练 mnist 数据的代码。

def train_and_test(dataset_url, training_iterations, batch_size, evaluation_interval):

    with make_reader(os.path.join(dataset_url, 'train'), num_epochs=None) as train_reader:
        with make_reader(os.path.join(dataset_url, 'test'), num_epochs=None) as test_reader:
            train_readout = tf_tensors(train_reader)
            train_image = tf.cast(tf.reshape(train_readout.image, [784]), tf.float32)
            train_label = train_readout.digit
            batch_image, batch_label = tf.train.batch(
                [train_image, train_label], batch_size=batch_size
            )

我不知道如何替换tf.train.batch。你能帮忙吗?

【问题讨论】:

    标签: python tensorflow petastorm


    【解决方案1】:

    您可以将dataset.batchtf.data.Dataset 一起使用,petastorm 还支持他们网站中提到的tf.data.Dataset

    有关使用petastorm 实现tf.data.Dataset 的代码,您可以获取它here
    有关dataset.batch的详细信息,您可以找到here

    【讨论】:

      猜你喜欢
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      • 2019-11-24
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-16
      相关资源
      最近更新 更多