【发布时间】:2020-10-06 10:12:44
【问题描述】:
我这样加载数据集:
import tensorflow_datasets as tfds
ds = tfds.load(
'caltech_birds2010',
split='train',
as_supervised=False)
这个功能很好用:
import tensorflow as tf
@tf.function
def pad(image,label):
return (tf.image.resize_with_pad(image,32,32),label)
ds = ds.map(pad)
但是当我尝试映射不同的内置函数时
from tf.keras.preprocessing.image import random_rotation
@tf.function
def rotate(image,label):
return (random_rotation(image,90), label)
ds = ds.map(rotate)
我收到以下错误:
AttributeError: 'Tensor' 对象没有属性 'ndim'
这不是唯一给我带来问题的函数,不管有没有 @tf.function 装饰器都会发生这种情况。
非常感谢任何帮助!
【问题讨论】:
标签: python tensorflow keras tensorflow-datasets