Skip to content

Commit

Permalink
maybe dont do auto naming in layers
Browse files Browse the repository at this point in the history
  • Loading branch information
henrysky committed Jul 19, 2024
1 parent 7210bb0 commit 240caa3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
4 changes: 1 addition & 3 deletions src/astroNN/models/apogee_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,9 +1233,7 @@ class DeNormAdd(keras.layers.Layer):
def __init__(self, norm, name=None, **kwargs):
self.norm = norm
self.supports_masking = True
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))

super().__init__(name=name, **kwargs)

def call(self, inputs, training=None):
Expand Down
27 changes: 0 additions & 27 deletions src/astroNN/nn/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class KLDivergenceLayer(Layer):

def __init__(self, name=None, **kwargs):
self.is_placeholder = True
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def call(self, inputs, training=None):
Expand Down Expand Up @@ -59,9 +56,6 @@ class VAESampling(Layer):

def __init__(self, name=None, **kwargs):
self.supports_masking = True
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def call(self, inputs):
Expand Down Expand Up @@ -90,9 +84,6 @@ def __init__(self, rate, disable=False, noise_shape=None, name=None, **kwargs):
self.disable_layer = disable
self.supports_masking = True
self.noise_shape = noise_shape
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def _get_noise_shape(self, inputs):
Expand Down Expand Up @@ -200,9 +191,6 @@ def __init__(self, rate, disable=False, name=None, **kwargs):
self.disable_layer = disable
self.supports_masking = True
self.rate = rate
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def call(self, inputs, training=None):
Expand Down Expand Up @@ -244,9 +232,6 @@ class ErrorProp(Layer):

def __init__(self, name=None, **kwargs):
self.supports_masking = True
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def call(self, inputs, training=None):
Expand Down Expand Up @@ -368,9 +353,6 @@ class FastMCInferenceMeanVar(Layer):
"""

def __init__(self, name=None, **kwargs):
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def compute_output_shape(self, input_shape):
Expand Down Expand Up @@ -413,9 +395,6 @@ class FastMCRepeat(Layer):

def __init__(self, n, name=None, **kwargs):
self.n = n
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def compute_output_shape(self, input_shape):
Expand Down Expand Up @@ -460,9 +439,6 @@ class StopGrad(Layer):
"""

def __init__(self, name=None, always_on=False, **kwargs):
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)
self.always_on = always_on

Expand Down Expand Up @@ -516,9 +492,6 @@ def __init__(self, mask, name=None, **kwargs):
self.boolmask = mask
self.mask_shape = self.boolmask.sum()
self.supports_masking = True
if not name:
prefix = self.__class__.__name__
name = prefix + "_" + str(keras.utils.naming.auto_name(prefix))
super().__init__(name=name, **kwargs)

def compute_output_shape(self, input_shape):
Expand Down
6 changes: 5 additions & 1 deletion src/astroNN/shared/nn_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
# ---------------------------------------------------------#
import datetime
import os
import keras
import inspect
import warnings
from astroNN.config import _KERAS_BACKEND

try:
import keras.src as keras
except ModuleNotFoundError:
import keras

# TODO: removed gpu_memory_manage() and gpu_availability() as they are not used in astroNN


Expand Down

0 comments on commit 240caa3

Please sign in to comment.