Skip to content

Commit 451ef6e

Browse files
committed
train.py: Write logs to output directory
Write logs to the output directory instead of a separate directory.
1 parent c2b5a20 commit 451ef6e

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

train.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
BIN_SAMPLE_SIZE = 40
1414
OUTPUT_DIR = 'output'
15-
LOG_DIR = 'logs'
1615
LATEST_LAST_PATH = ''
1716
LATEST_BEST_PATH = ''
1817
LATEST_EPOCH_PATH = ''
@@ -68,18 +67,6 @@ def prepare_output_directory():
6867
return path
6968

7069

71-
def prepare_log_directory():
72-
path = LOG_DIR
73-
if not os.path.exists(path):
74-
os.mkdir(path)
75-
val = 1
76-
while os.path.exists(path+'/'+str(val)):
77-
val += 1
78-
path = path + '/' + str(val)
79-
os.mkdir(path)
80-
return path
81-
82-
8370
def calculate_validation_loss(nnue, val_data_loader, lambda_):
8471
nnue.eval()
8572
with torch.no_grad():
@@ -135,10 +122,8 @@ def main(args):
135122
else:
136123
main_device = 'cpu'
137124

138-
# Create directories to store data and logs in
125+
# Create directories to store data in
139126
output_path = prepare_output_directory()
140-
if args.log:
141-
log_path = prepare_log_directory()
142127

143128
# Print configuration info
144129
print(f'Device: {main_device}')
@@ -149,13 +134,13 @@ def main(args):
149134
print(f'Lambda: {args.lambda_}')
150135
print(f'Validation check interval: {args.val_check_interval}')
151136
if args.log:
152-
print(f'Logs written to: {log_path}')
137+
print(f'Logs written to: {output_path}')
153138
print(f'Data written to: {output_path}')
154139
print('')
155140

156141
# Create log writer
157142
if args.log:
158-
writer = SummaryWriter(log_path)
143+
writer = SummaryWriter(output_path)
159144

160145
# Create data loaders
161146
train_size = int(os.path.getsize(args.train)/BIN_SAMPLE_SIZE)

0 commit comments

Comments
 (0)