我遇到以下问题。我想使用CIFAR10-数据集(更具体地说,我将分别学习本课程,并且正在尝试进行第一个作业http://cs231n.github.io/assignments2018/assignment1/)。
当我第一次执行linear_svm的代码时,数据集已加载,一切正常。但是,如果我关闭它并重新打开它,并尝试从头开始再次运行每个卖出,那么当我尝试再次加载数据集时,它会卡住。如果要修复此问题,请重置笔记本,然后解决。但是现在,我保存了它,因为进行了一些更改,但我无法再次执行此操作。有人可以帮我吗?最近几个月我开始学习python,所以我不知道出了什么问题。
第一个单元格的代码是:
# Run some setup code for this notebook.
from __future__ import print_function
import random
import numpy as np
from cs231n.data_utils import load_CIFAR10
import matplotlib.pyplot as plt
# This is a bit of magic to make matplotlib figures appear inline in the
# notebook rather than in a new window.
%matplotlib inline
plt.rcParams['figure.figsize'] = (10.0, 8.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
# Some more magic so that the notebook will reload external python modules;
# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython
%load_ext autoreload
%autoreload 2
然后第二个单元格是
#Load the raw CIFAR-10 data.
cifar10_dir = 'cs231n/datasets/cifar-10-batches-py'
# Cleaning up variables to prevent loading data multiple times (which may cause memory issue)
X_train, y_train, X_test, y_test = load_CIFAR10(cifar10_dir)
# As a sanity check, we print out the size of the training and test data.
print('Training data shape: ', X_train.shape)
print('Training labels shape: ', y_train.shape)
print('Test data shape: ', X_test.shape)
print('Test labels shape: ', y_test.shape)
注意:原始笔记本中的命令“ from future import print_function”位于所有导入命令之后。但是当我运行此单元格时,它告诉我它应该在文件的开头。
我将不胜感激!我是python和机器学习的初学者,目前我深陷其中!谢谢