当我在代码下运行以从压缩的.tar.gz文件中提取数据集时,我收到以下错误。 maybe_extract函数尝试从.tar.gz文件中提取数据。有人能告诉我这里有什么问题吗?
代码:
while x < letters.to_a.length
"letter_code[ #{letters.to_a[x]} ]=#{code[x]}"
x += 1
end
puts "#{letter_code}"
错误:
num_classes = 10
np.random.seed(133)
def maybe_extract(filename, force=False):
root = os.path.splitext(os.path.splitext(filename)[0])[0] # remove .tar.gz
if os.path.isdir(root) and not force:
# You may override by setting force=True.
print('%s already present - Skipping extraction of %s.' % (root, filename))
else:
print('Extracting data for %s. This may take a while. Please wait.' % root)
tar = tarfile.open(filename)
sys.stdout.flush()
tar.extractall()
tar.close()
data_folders = [os.path.join(root, d) for d in sorted(os.listdir(root)) if os.path.isdir(os.path.join(root, d))]
if len(data_folders) != num_classes:
raise Exception('Expected %d folders, one per class. Found %d instead.' % (num_classes, len(data_folders)))
print(data_folders)
return data_folders
train_folders = maybe_extract(train_filename)
test_folders = maybe_extract(test_filename)