Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Fix for python 3.7 & using TensorBoard Callback #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions optkeras/optkeras.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from datetime import datetime
from pathlib import Path
from inspect import signature

import optuna

Expand Down Expand Up @@ -302,8 +303,6 @@ def on_epoch_end(self, epoch, logs={}):
self.datetime_epoch_end = self.get_datetime()
# Add error and val_error to logs for use as an objective to minimize

logs['_Datetime_epoch_begin'] = self.datetime_epoch_begin
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these removed?

logs['_Datetime_epoch_end'] = self.datetime_epoch_end
logs['_Trial_num'] = self.trial.number
# Update the best logs

Expand Down Expand Up @@ -364,7 +363,7 @@ def random_grid_search(self, func, n_trials, **kwargs):


def get_trial_default():
num_fields = optuna.structs.FrozenTrial._field_types.__len__()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code work with Python 3.6 in addition to Python 3.7?

num_fields = len(signature(optuna.structs.FrozenTrial).parameters)
assert num_fields in (10, 11, 12)
if num_fields == 12: # possible future version
return optuna.structs.FrozenTrial(
Expand Down