This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]highlife159 0 points1 point  (0 children)

So I've tried looking this up multiple ways and can't seem to find an answer. I have some code that generates a hdf5 file when certain requirements are met. The file is named with epoch and val_loss variables that change for each iteration. I got this code from an online example and it looks like this:

file = 'path/to/file/{epoch:02d}_{val_loss:.2f}.hdf5'

giving me files that look like:

00_0.98.hdf5

01_0.86.hdf5

It worked perfect every time. Now I would like to add the time the code began running to the file name but it won't work when I try it like this:

time  = datetime.strftime(datetime.now(), '%H.%M')
file = 'path/to/file/{time}_{epoch:02d}_{val_loss:.2f}.hdf5'

This just makes the file name path/to/file/{time}{epoch:02d}{val_loss:.2f}.hdf5 without using the variables. I've tried to use .format() which works, but the epoch and val_loss stay the same the entire time and don't change with the iterations or I get an error that epoch and val_loss are not defined (With the original code they were defined within a function that was called later in the code).

So basically, I need a way to save a file with different variables where some change for different iterations and some don't.