Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class StatelessMetric(JavaValue):
def __init__(self, metric_name, idx):
self.name = metric_name
self.idx = idx
JavaValue.__init__(self, None, "float", metric_name, idx)
class BigDLMetric(object):
def __init__(self, val_method, outputs, labels):
self.val_method = val_method
self.outputs = outputs
self.labels = labels
class TFTrainingHelper(Layer):
def __init__(self, path, config_proto, saver, meta, sess):
self.saver = saver
self.meta = meta
self.export_dir = path
self.sess = sess
if config_proto is not None:
import tensorflow as tf
assert isinstance(config_proto, tf.ConfigProto), \
"session_config should be a tf.ConfigProto"
config_proto.use_per_session_threads = True
byte_arr = bytearray(config_proto.SerializeToString())
else:
byte_arr = None
super(TFTrainingHelper, self).__init__(None, "float", path, byte_arr)
def _do_load(jmodel, bigdl_type="float"):
model = Layer(jvalue=jmodel, bigdl_type=bigdl_type)
model.value = jmodel
return model
Return a list of shape tuples if there are multiple outputs.
Return one shape tuple otherwise.
"""
output = callBigDlFunc(self.bigdl_type, "getOutputShape",
self.value)
return self.__process_shape(output)
class KerasCreator(JavaValue):
def jvm_class_constructor(self):
name = "createKeras" + self.__class__.__name__
print("creating: " + name)
return name
class KerasLayer(Layer, InferShape, KerasCreator):
def __init__(self, jvalue, *args, **kwargs):
allowed_kwargs = {"name", "bigdl_type"}
for kwarg in kwargs.keys():
if kwarg not in allowed_kwargs:
raise TypeError("Wrong argument for the layer:", kwarg)
bigdl_type = kwargs.get("bigdl_type")
if not bigdl_type:
bigdl_type = "float"
super(KerasCreator, self).__init__(jvalue, bigdl_type, *args)
name = kwargs.get("name")
if name:
self.set_name(name)
class Input(Node, KerasCreator):
"""
return results.map(lambda result: Layer.convert_output(result))
else:
return results.map(lambda result: Layer.convert_output(result))
else:
return results.map(lambda result: Layer.convert_output(result))
else: