mirror of
https://github.com/wassname/ray.git
synced 2026-07-25 13:30:52 +08:00
[tune] Support TF2.0 on Keras Callback (#5912)
This commit is contained in:
@@ -6,7 +6,8 @@ FROM ray-project/base-deps
|
||||
# a test runner.
|
||||
RUN conda install -y numpy
|
||||
RUN pip install -U pip
|
||||
RUN pip install -U https://ray-wheels.s3-us-west-2.amazonaws.com/latest/ray-0.8.0.dev6-cp36-cp36m-manylinux1_x86_64.whl boto3
|
||||
RUN pip install -U https://ray-wheels.s3-us-west-2.amazonaws.com/latest/ray-0.8.0.dev6-cp36-cp36m-manylinux1_x86_64.whl || pip install -U https://ray-wheels.s3-us-west-2.amazonaws.com/latest/ray-0.8.0.dev5-cp36-cp36m-manylinux1_x86_64.whl
|
||||
RUN pip install -U boto3
|
||||
# We install this after the latest wheels -- this should not override the latest wheels.
|
||||
RUN apt-get install -y zlib1g-dev
|
||||
# The following is needed to support TensorFlow 1.14
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import keras
|
||||
from tensorflow import keras
|
||||
from ray.tune import track
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ class TuneReporterCallback(keras.callbacks.Callback):
|
||||
for metric in list(logs):
|
||||
if "loss" in metric and "neg_" not in metric:
|
||||
logs["neg_" + metric] = -logs[metric]
|
||||
print(logs)
|
||||
if "acc" in logs:
|
||||
self.reporter(keras_info=logs, mean_accuracy=logs["acc"])
|
||||
else:
|
||||
@@ -45,4 +44,7 @@ class TuneReporterCallback(keras.callbacks.Callback):
|
||||
for metric in list(logs):
|
||||
if "loss" in metric and "neg_" not in metric:
|
||||
logs["neg_" + metric] = -logs[metric]
|
||||
self.reporter(keras_info=logs, mean_accuracy=logs["acc"])
|
||||
if "acc" in logs:
|
||||
self.reporter(keras_info=logs, mean_accuracy=logs["acc"])
|
||||
else:
|
||||
self.reporter(keras_info=logs, mean_accuracy=logs.get("accuracy"))
|
||||
|
||||
Reference in New Issue
Block a user