Python(Pytorch)-循环和日志记录
我对Python非常陌生,需要一些帮助以不同的历元数循环ANN 代码以Python(Pytorch)-循环和日志记录,python,loops,logging,pytorch,Python,Loops,Logging,Pytorch,我对Python非常陌生,需要一些帮助以不同的历元数循环ANN 代码以 import sys from tqdm import tqdm import numpy as np import torch import torch.nn.functional as F try: 时代部分呢 for t in range(2000): prediction = net(x) 我可以问一下我应该添加什么(在当前代码之前和之后)来循环程序3次,然后添加1000个epoch并再次运行,直到epoch
import sys
from tqdm import tqdm
import numpy as np
import torch
import torch.nn.functional as F
try:
时代部分呢
for t in range(2000):
prediction = net(x)
我可以问一下我应该添加什么(在当前代码之前和之后)来循环程序3次,然后添加1000个epoch并再次运行,直到epoch达到10000
非常感谢
另外,我想知道循环后,如何保存结果日志
loss_func = torch.nn.MSELoss()
将for循环更新为:
import sys
# To log your outputs in a separate file "myErrorLog.txt"
sys.stdout = open("myErrorLog.txt", "w")
for t in range(2000, 10000, 1000):
print ("iteration {}".format(t))
# your work here
# end of your code
sys.stdout.close()
请再解释一下,你想为10000个时代运行你的程序吗?是的。从2000年到10000年。每次添加1000个纪元,然后将for循环更新为范围(2000、10000、1000)内t的
: