[autoreload of cs231n.classifiers.fc_net failed: Traceback (most recent call last):
File "D:\miniconda\lib\site-packages\IPython\extensions\autoreload.py", line 276, in check
superreload(m, reload, self.old_objects)
File "D:\miniconda\lib\site-packages\IPython\extensions\autoreload.py", line 475, in superreload
module = reload(module)
File "D:\miniconda\lib\importlib\__init__.py", line 169, in reload
_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 619, in _exec
File "<frozen importlib._bootstrap_external>", line 879, in exec_module
File "<frozen importlib._bootstrap_external>", line 1017, in get_code
File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "D:\cs231n.github.io-master\assignments\2021\assignment2_colab\assignment2\cs231n\classifiers\fc_net.py", line 80
self.params['W' + str(i + 1)] = np.random.randn(layer_dims[i], layer_dims[i + 1]) * weight_scale
TabError: inconsistent use of tabs and spaces in indentation
]
---------------------------------------------------------------------------
AxisError Traceback (most recent call last)
Cell In[5], line 28
14 model = FullyConnectedNet(
15 [100, 100],
16 weight_scale=weight_scale,
17 dtype=np.float64
18 )
19 solver = Solver(
20 model,
21 small_data,
(...)
26 optim_config={"learning_rate": learning_rate},
27 )
---> 28 solver.train()
30 plt.plot(solver.loss_history)
31 plt.title("Training loss history")
File D:\cs231n.github.io-master\assignments\2021\assignment2_colab\assignment2\cs231n\solver.py:285, in Solver.train(self)
283 last_it = t == num_iterations - 1
284 if first_it or last_it or epoch_end:
--> 285 train_acc = self.check_accuracy(
286 self.X_train, self.y_train, num_samples=self.num_train_samples
287 )
288 val_acc = self.check_accuracy(
289 self.X_val, self.y_val, num_samples=self.num_val_samples
290 )
291 self.train_acc_history.append(train_acc)
File D:\cs231n.github.io-master\assignments\2021\assignment2_colab\assignment2\cs231n\solver.py:248, in Solver.check_accuracy(self, X, y, num_samples, batch_size)
246 end = (i + 1) * batch_size
247 scores = self.model.loss(X[start:end])
--> 248 y_pred.append(np.argmax(scores, axis=1))
249 y_pred = np.hstack(y_pred)
250 acc = np.mean(y_pred == y)
File D:\miniconda\lib\site-packages\numpy\_core\fromnumeric.py:1342, in argmax(a, axis, out, keepdims)
1253 """
1254 Returns the indices of the maximum values along an axis.
1255
(...)
1339 (2, 1, 4)
1340 """
1341 kwds = {'keepdims': keepdims} if keepdims is not np._NoValue else {}
-> 1342 return _wrapfunc(a, 'argmax', axis=axis, out=out, **kwds)
File D:\miniconda\lib\site-packages\numpy\_core\fromnumeric.py:54, in _wrapfunc(obj, method, *args, **kwds)
52 bound = getattr(obj, method, None)
53 if bound is None:
---> 54 return _wrapit(obj, method, *args, **kwds)
56 try:
57 return bound(*args, **kwds)
File D:\miniconda\lib\site-packages\numpy\_core\fromnumeric.py:46, in _wrapit(obj, method, *args, **kwds)
43 # As this already tried the method, subok is maybe quite reasonable here
44 # but this follows what was done before. TODO: revisit this.
45 arr, = conv.as_arrays(subok=False)
---> 46 result = getattr(arr, method)(*args, **kwds)
48 return conv.wrap(result, to_scalar=False)
AxisError: axis 1 is out of bounds for array of dimension 1
最新发布