train_horses = train_horses.map(
preprocess_image_train, num_parallel_calls=AUTOTUNE).cache().shuffle(
BUFFER_SIZE).batch(1)
train_zebras = train_zebras.map(
preprocess_image_train, num_parallel_calls=AUTOTUNE).cache().shuffle(
BUFFER_SIZE).batch(1)
test_horses = test_horses.map(
preprocess_image_test, num_parallel_calls=AUTOTUNE).cache().shuffle(
BUFFER_SIZE).batch(1)
test_zebras = test_zebras.map(
preprocess_image_test, num_parallel_calls=AUTOTUNE).cache().shuffle(
BUFFER_SIZE).batch(1)
这段代码中的错误是什么,它显示属性错误,我无法解决它。
错误是:
AttributeError Traceback (most recent call last)
<ipython-input-15-00c14af042b9> in <module>()
----> 1 train_horses = train_horses.map(
2 preprocess_image_train, num_parallel_calls=AUTOTUNE).cache().shuffle(
3 BUFFER_SIZE).batch(1)
4
5 train_zebras = train_zebras.map(
AttributeError: 'list'对象没有属性'map'
链接到COLAB:https://colab.research.google.com/drive/1rlgjFnhPGJTjUv368imG9q1VEGQZ0N13?usp=sharing
错误信息完全正确。列表没有map
属性。有两种可能。train_horses
应该是一个不同的类型(numpy
数组,也许?)或者你打算使用独立的映射函数:
test_horses = map( test_horses,
preprocess_image_train, num_parallel_calls=AUTOTUNE).cache().shuffle(
BUFFER_SIZE).batch(1)
您试图在此输出上调用cache
,shuffle
和batch
这一事实强烈表明问题是前者,因为map
结果没有这些属性。test_horses
应该是另一种物体。你没有告诉我们你是如何创建它的,所以我们不能提供更多的帮助。
后续
num_parallel_calls
是一个TensorFlow张量属性。所以,显然你打算把test_horses
变成一个张量,但你忘了这么做。