我使用tiny-imagenet包出现问题。
typeerror: __init__() got an unexpected keyword argument 'urls'
包可以从
Linux:
/home/<用户名>/anaconda3/envs/<虚拟环境名>/lib/python<版本号>/site-packages/
windows:
C:\Users\<用户名>\Anaconda3\envs\<虚拟环境名>\Lib\site-packages\
中去找。
我的报错位置如下:
def _info(self):
return tfds.core.DatasetInfo(
builder=self,
description=("""Tiny ImageNet Challenge is a similar challenge as ImageNet with a smaller dataset but
less image classes. It contains 200 image classes, a training
dataset of 100, 000 images, a validation dataset of 10, 000
images, and a test dataset of 10, 000 images. All images are
of size 64×64."""),
features=tfds.features.FeaturesDict({
"image": tfds.features.Image(shape=(64, 64, 3), encoding_format="jpeg"),
"id": tfds.features.Text(),
"label": tfds.features.ClassLabel(num_classes=200),
}),
supervised_keys=("image", "label"),
urls=["https://tiny-imagenet.herokuapp.com/"],
citation=r"""@article{tiny-imagenet,
author = {Li,Fei-Fei}, {Karpathy,Andrej} and {Johnson,Justin}"}""",
)
问题出现在tfds.core.DatasetInfo这个类,其中使用了urls参数。
所以,可以合理推断是下载的tfds(tensorflow_datasets)的版本不对。
到github看tiny-imagenet上传的大致时间,根据该时间推测作者最有可能使用的tensorflow_datasets的版本,然后我安装了tensorflow_datasets 2.0.0的版本,发现问题。
原来是自tensorflow_datasets 2.0.0起,urls被淘汰了,改用homepages。
修改tiny_imagenet的错误部分,结果如下:
def _info(self):
return tfds.core.DatasetInfo(
builder=self,
description=("""Tiny ImageNet Challenge is a similar challenge as ImageNet with a smaller dataset but
less image classes. It contains 200 image classes, a training
dataset of 100, 000 images, a validation dataset of 10, 000
images, and a test dataset of 10, 000 images. All images are
of size 64×64."""),
features=tfds.features.FeaturesDict({
"image": tfds.features.Image(shape=(64, 64, 3), encoding_format="jpeg"),
"id": tfds.features.Text(),
"label": tfds.features.ClassLabel(num_classes=200),
}),
supervised_keys=("image", "label"),
homepage="https://tiny-imagenet.herokuapp.com/",
citation=r"""@article{tiny-imagenet,
author = {Li,Fei-Fei}, {Karpathy,Andrej} and {Johnson,Justin}"}""",
)
urls一行变成了 homepage="https://tiny-imagenet.herokuapp.com/"
问题解决啦~~~~~