-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors in train_ch3 in tensorflow version softmax-regression-scratch.ipynb #2577
Comments
Here is another bug in the last cell of softmax-regression-concise.ipynb Here is the bug detail AssertionError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/d2l/tensorflow.py in train_ch3(net, train_iter, test_iter, loss, num_epochs, updater) AssertionError: 0.5710129758199056ImportError Traceback (most recent call last) 12 frames 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: