Skip to content
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

fixed RemoteMonitor: Json to handle np.float32 and np.int32 types #9261

Merged
merged 6 commits into from
Feb 2, 2018
4 changes: 4 additions & 0 deletions keras/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ def on_epoch_end(self, epoch, logs=None):
send['epoch'] = epoch
for k, v in logs.items():
send[k] = v
if isinstance(v, (np.float16, np.float32)):
send[k] = np.float64(v)
elif isinstance(v, (np.int16, np.int32)):
send[k] = np.int64(v)
Copy link
Collaborator

Choose a reason for hiding this comment

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

if isinstance(v, np.ndarray):
    send[k] = v.item()
else:
    send[k] = v

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed as per suggestion,Travis build failed due to some tensorflow installation error,I guess re-running the test will pass the PR

try:
requests.post(self.root + self.path,
{self.field: json.dumps(send)},
Expand Down