Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python(Pytorch)-循环和日志记录_Python_Loops_Logging_Pytorch - Fatal编程技术网

Python(Pytorch)-循环和日志记录

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

我对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达到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的