Skip to content

Commit

Permalink
remove dependence of 'pandas'
Browse files Browse the repository at this point in the history
  • Loading branch information
308188605@qq.com committed Aug 9, 2019
1 parent 5475e7b commit bf4f141
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
32 changes: 25 additions & 7 deletions jdit/trainer/super.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

import os
import random
import pandas as pd
# import pandas as pd
import csv
import numpy as np

from functools import wraps
Expand Down Expand Up @@ -500,8 +501,14 @@ def regist_config(self, opt_model_data: Union[SupTrainer, Optimizer, Model, Data
if epoch is not None:
config_dic.update({"epoch": epoch})
config_dic.update(obj_config_dic)
pdg = pd.DataFrame.from_dict(config_dic, orient="index").transpose()
pdg.to_csv(path, mode="w", encoding="utf-8", index=False, header=True)
# pdg = pd.DataFrame.from_dict(config_dic, orient="index").transpose()
# pdg.to_csv(path, mode="w", encoding="utf-8", index=False, header=True)
with open(path, "w", encoding="utf-8") as csvfile:
writer = csv.writer(csvfile)
# 先写入columns_name
writer.writerow(config_dic.keys())
# 写入多行用writerows
writer.writerow(config_dic.values())
else:
# 已经注册过config
last_config = self.regist_dict[config_filename]
Expand All @@ -514,8 +521,14 @@ def regist_config(self, opt_model_data: Union[SupTrainer, Optimizer, Model, Data
if epoch is not None:
config_dic.update({"epoch": epoch})
config_dic.update(obj_config_dic)
pdg = pd.DataFrame.from_dict(config_dic, orient="index").transpose()
pdg.to_csv(path, mode="a", encoding="utf-8", index=False, header=False)
# pdg = pd.DataFrame.from_dict(config_dic, orient="index").transpose()
# pdg.to_csv(path, mode="a", encoding="utf-8", index=False, header=False)
with open(path, "a", encoding="utf-8") as csvfile:
writer = csv.writer(csvfile)
# 先写入columns_name
# writer.writerow(config_dic.keys())
# 写入多行用writerows
writer.writerow(config_dic.values())

def write(self, step: int, current_epoch: int, msg_dic: dict, filename: str, header=True):
if msg_dic is None:
Expand All @@ -527,8 +540,13 @@ def write(self, step: int, current_epoch: int, msg_dic: dict, filename: str, hea
path = os.path.join(self.logdir, filename + ".csv")
dic = dict({"step": step, "current_epoch": current_epoch})
dic.update(msg_dic)
pdg = pd.DataFrame.from_dict(dic, orient="index").transpose()
pdg.to_csv(path, mode="a", encoding="utf-8", index=False, header=header)
# pdg = pd.DataFrame.from_dict(dic, orient="index").transpose()
# pdg.to_csv(path, mode="a", encoding="utf-8", index=False, header=header)
with open(path, "a", encoding="utf-8") as csvfile:
writer = csv.writer(csvfile)
if header:
writer.writerow(dic.keys())
writer.writerow(dic.values())

def clear_regist(self):
self.regist_dict = dict({})
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ tensorflow
tensorboard
tqdm
imageio
pandas
Pillow
psutil
numpy
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="jdit", # pypi中的名称,pip或者easy_install安装时使用的名称,或生成egg文件的名称
version="0.1.0",
version="0.1.1",
author="Guanglei Ding",
author_email="dingguanglei.bupt@qq.com",
maintainer='Guanglei Ding',
Expand Down

0 comments on commit bf4f141

Please sign in to comment.