-
Notifications
You must be signed in to change notification settings - Fork 390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can History be more powerful? #804
Comments
I assume that you suggest to (optionally) use pickle when calling
Persisting the Another thing to be aware of: You can easily dump the history into a pandas DataFrame and then use pandas to persist into a lot of different formats, such as csv (but this is a one way street): df = pd.DataFrame(net.history[:, ['train_loss', 'valid_loss', 'valid_loss_best']])
df.to_csv('history.csv') (this won't work for the
What exactly do you mean? Could you give an example of how that looks like in usage? The only reference I could find was this experimental feature without any further explanation :) |
@BenjaminBossan
That's reasonable. If I want to add this feature without modifying In my opinion, saving history in JSON type is feasible, but I wonder if anyone is willing to open that JSON file then checking these values with human eyes :P So just advice, maybe it is better to be persisted in binary files. Or at least, we can decide the method of persisting by an additional argument or global setting or something.
I didn't expect the PANDAS official documents not to say a word about An expected usage: H = History()
# Initial state: H.attrs: dict = {}
# Assuming H has been recorded for many epochs
H.attrs["last_record_time"] = time.time()
H.attrs["best_valid_epoch"] = np.argmin(H[:,"valid_loss"])
H.attrs["earlystopping_count"] = 20
# ... Other attributes, which do not belong to any epoch, so they can't be saved in History list.
H.to_file() # Save history list and H.attrs together |
Why not override
I think it would be possible to add an argument to
As long as you're happy to save the history as a pickle file, you can just add your own class MyNet(NeuralNet):
def on_train_end(self, net, X=None, y=None, **kwargs):
h = self.history
h.attrs = {}
h.attrs['foo'] = 123
... Obviously, if dumped as a JSON, |
Yeah, the easiest way is to modify the History.to_file method. But that requires modifying the source code. So I'd super appreciated that if your team are willing to do these changes, for example, add an argument or something. Saving in JSON type guarantees compatibility, that's right, I think that makes sense. But in exchange, it loses flexibility, and perhaps time and space. Now I'm using my customized History.to_file and it works pretty well for me. Anyway, thanks for all these replies and advice :) |
Okay, so let's boil down the discussion so far:
These all sound reasonable to me. When I have time in the future, I'll take a look at them, at least 1. shouldn't be too hard. Of course, if you want to create a PR in the meantime, that would be highly welcome ;) |
The current History class has some limitations: (ver 0.10.0)
According to the above-mentioned limitations, maybe it is better for History to be saved as binary files (In my computer I've modified
history.py
and changed alljson
topickle
and it works pretty well). Besides, adding adict
into History class (likeattrs
dict in pandas.DataFrame) so that additional contents can be easily saved.The text was updated successfully, but these errors were encountered: