You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
12 frames /usr/local/lib/python3.10/dist-packages/matplotlib/backends/backend_svg.py in
16 import matplotlib as mpl
17 from matplotlib import _api, cbook, font_manager as fm
---> 18 from matplotlib.backend_bases import (
19 _Backend, _check_savefig_extra_args, FigureCanvasBase, FigureManagerBase,
20 RendererBase)
ImportError: cannot import name '_check_savefig_extra_args' from 'matplotlib.backend_bases' (/usr/local/lib/python3.10/dist-packages/matplotlib/backend_bases.py)
Here is the function that causes an error when I use train_ch3(net, train_iter, test_iter, cross_entropy, num_epochs, updater)
in the softmax-regression-scratch.ipynb
def train_ch3(net, train_iter, test_iter, loss, num_epochs, updater):
"""动画+训练模型(定义见第3章)"""
animator = Animator(xlabel='epoch', xlim=[1, num_epochs], ylim=[0.3, 0.9],
legend=['train loss', 'train acc', 'test acc'])
for epoch in range(num_epochs):
train_metrics = train_epoch_ch3(net, train_iter, loss, updater)
##NameError: name 'train_epoch_ch3' is not defined
test_acc = evaluate_accuracy(net, test_iter)
animator.add(epoch + 1, train_metrics + (test_acc,))
train_loss, train_acc = train_metrics
assert train_loss < 0.5, train_loss
assert train_acc <= 1 and train_acc > 0.7, train_acc
assert test_acc <= 1 and test_acc > 0.7, test_acc
Here is the bug details
NameError Traceback (most recent call last)
in <cell line: 2>()
1 num_epochs = 10
----> 2 train_ch3(net, train_iter, test_iter, cross_entropy, num_epochs, updater)
in train_ch3(net, train_iter, test_iter, loss, num_epochs, updater)
4 legend=['train loss', 'train acc', 'test acc'])
5 for epoch in range(num_epochs):
----> 6 train_metrics = train_epoch_ch3(net, train_iter, loss, updater)
7 test_acc = evaluate_accuracy(net, test_iter)
8 animator.add(epoch + 1, train_metrics + (test_acc,))
NameError: name 'train_epoch_ch3' is not defined
The text was updated successfully, but these errors were encountered: