You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use this package as a custom layer with tensorflow (keras).
My code looks at the moment like this:
@tf.functiondefelastic_deform_tf(x):
""" Elastic deformation layer. Args: x : a Tensor(batch_size, height, width, channels) of images to preprocess Returns: Images on which elastic deform was applied. """x=tf.reshape(x, (x.shape[0], 64, 64))
x=tf.cast(x, tf.float32)
# generate a deformation griddisplacement=np.random.randn(3, 1, 1, 1) *2# perform forward deformationx_deformed=edf.tf.deform_grid(x, displacement)
returnx_deformedclassElasticDeformTFLayer(tf.keras.layers.Layer):
def__init__(self, name="elastic_deform_tf", **kwargs):
super(ElasticDeformTFLayer, self).__init__(name=name, **kwargs)
self.preprocess=elastic_deform_tfdefcall(self, input):
returnself.preprocess(input)
defget_config(self):
config=super(ElasticDeformTFLayer, self).get_config()
returnconfig
However this is very slow and is not running on the GPU.
Therefore it would be very nice if this package could add a layer which can be used in TF for ML models.
The text was updated successfully, but these errors were encountered:
I am trying to use this package as a custom layer with tensorflow (keras).
My code looks at the moment like this:
However this is very slow and is not running on the GPU.
Therefore it would be very nice if this package could add a layer which can be used in TF for ML models.
The text was updated successfully, but these errors were encountered: