我正在尝试阅读《自动驾驶汽车的应用深度学习和计算机视觉》这本书。我在运行一些示例代码时遇到了 keras 问题。当尝试使用 get_file() 函数获取文件时,我收到类型错误。 系统:Windows 10 | Python 3.9.19 |张量流 2.10.1
代码片段:
dataset_path = keras.utils.get_file("auto-mpg.data", "https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data")
结果错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[2], line 2
1 # Datapath to import auto-mpg data
----> 2 dataset_path = keras.utils.get_file("auto-mpg.data", "https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data")
File ~\anaconda3\envs\AVTech\lib\site-packages\keras\utils\data_utils.py:296, in get_file(fname, origin, untar, md5_hash, file_hash, cache_subdir, hash_algorithm, extract, archive_format, cache_dir)
294 try:
295 try:
--> 296 urlretrieve(origin, fpath, DLProgbar())
297 except urllib.error.HTTPError as e:
298 raise Exception(error_msg.format(origin, e.code, e.msg))
File ~\anaconda3\envs\AVTech\lib\site-packages\keras\utils\data_utils.py:86, in urlretrieve(url, filename, reporthook, data)
84 response = urlopen(url, data)
85 with open(filename, "wb") as fd:
---> 86 for chunk in chunk_read(response, reporthook=reporthook):
87 fd.write(chunk)
File ~\anaconda3\envs\AVTech\lib\site-packages\keras\utils\data_utils.py:78, in urlretrieve.<locals>.chunk_read(response, chunk_size, reporthook)
76 count += 1
77 if reporthook is not None:
---> 78 reporthook(count, chunk_size, total_size)
79 if chunk:
80 yield chunk
File ~\anaconda3\envs\AVTech\lib\site-packages\keras\utils\data_utils.py:287, in get_file.<locals>.DLProgbar.__call__(self, block_num, block_size, total_size)
285 self.progbar = Progbar(total_size)
286 current = block_num * block_size
--> 287 if current < total_size:
288 self.progbar.update(current)
289 elif not self.finished:
TypeError: '<' not supported between instances of 'int' and 'NoneType'