ADD file via upload

This commit is contained in:
Tuberrr 2024-08-03 00:45:59 +08:00
parent 6da390e100
commit 4e8a10f1ba
1 changed files with 25 additions and 0 deletions

25
utilis.py Normal file
View File

@ -0,0 +1,25 @@
import torch
import datetime
import os
def save_result(data, ylabel, args):
data = {'base' :data}
path = './output'
file = '{}_{}.txt'.format(args.algorithm, datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S"))
if not os.path.exists(path):
os.makedirs(path)
with open(os.path.join(path,file), 'a') as f:
for label in data:
f.write(label)
f.write(' ')
for item in data[label]:
item1 = str(item)
f.write(item1)
f.write(' ')
f.write('\n')
print('save finished')
f.close()