module 'cifar10' has no attribute 'maybe_download_and_extract'

使用TensorFlow进行Cifar数据集实验,使用官方提供的cifar.py下载数据报错:module ‘cifar10’ has no attribute ‘maybe_download_and_extract’

这段时间学习TensorFlow的使用,按照官方教程进行Cifar数据集上的实验。看到有代码cifar10.maybe_download_and_extract()用来下载数据,但是实际运行时报错cifar.py中没有该函数。

在cifar10.py中找到这样一行函数:

images, labels = cifar10_input.distorted_inputs(batch_size=FLAGS.batch_size)

然后在cifar10_input.py中找到函数disorted_inputs:

return _get_images_labels(batch_size, tfds.Split.TRAIN, distords=True)

再跳转:

def _get_images_labels(batch_size, split, distords=False):
  """Returns Dataset for given split."""
  dataset = tfds.load(name='cifar10', split=split)
  scope = 'data_augmentation' if distords else 'input'
  with tf.name_scope(scope):
    dataset = dataset.map(DataPreprocessor(distords), num_parallel_calls=10)
  # Dataset is small enough to be fully loaded on memory:
  dataset = dataset.prefetch(-1)
  dataset = dataset.repeat().batch(batch_size)
  iterator = dataset.make_one_shot_iterator()
  images_labels = iterator.get_next()
  images, labels = images_labels['input'], images_labels['target']
  tf.summary.image('images', images)
  return images, labels

其中第一句不就正是数据的加载吗,也就是说在这个代码中使用了tfds.load加载了cifar数据集。
后来查资料知道tfds是tensorflow官方新给出的工具包tensorflow_datasets,用这个包可以轻松的下载很多数据集。之后我也打算学习一下这个包的使用。
因此,在使用cifar.py搭建模型,训练数据时不必在专门下载数据,其代码中已经内置好了下载。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值