Skip to content

Commit

Permalink
Modify absolute imports to relative ones
Browse files Browse the repository at this point in the history
  • Loading branch information
keisen committed Jun 6, 2021
1 parent 3127bf5 commit 020c199
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 44 deletions.
2 changes: 1 addition & 1 deletion tf_keras_vis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import tensorflow as tf

from tf_keras_vis.utils import listify
from .utils import listify


class ModelVisualization(ABC):
Expand Down
38 changes: 19 additions & 19 deletions tf_keras_vis/activation_maximization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
import tensorflow.keras.backend as K
from packaging.version import parse as version

from tf_keras_vis import ModelVisualization
from tf_keras_vis.utils import (get_num_of_steps_allowed, is_mixed_precision, listify,
lower_precision_dtype)
from tf_keras_vis.utils.input_modifiers import Jitter, Rotate2D
from tf_keras_vis.utils.regularizers import Norm, TotalVariation2D
from .. import ModelVisualization
from ..utils import get_num_of_steps_allowed, is_mixed_precision, listify
from .input_modifiers import Jitter, Rotate2D
from .regularizers import Norm, TotalVariation2D

if version(tf.version.VERSION) >= version("2.4.0"):
from tensorflow.keras.mixed_precision import LossScaleOptimizer
Expand All @@ -23,20 +22,21 @@ class ActivationMaximization(ModelVisualization):
Todo:
* Write examples
"""
def __call__(self,
score,
seed_input=None,
input_range=(0, 255),
input_modifiers=[Jitter(jitter=8), Rotate2D(degree=3)],
regularizers=[TotalVariation2D(weight=1.0),
Norm(weight=1.0, p=2)],
steps=200,
optimizer=None, # When None, the default is tf.optimizers.RMSprop(1.0, 0.999)
normalize_gradient=None, # Disabled option.
gradient_modifier=None,
callbacks=None,
training=False,
unconnected_gradients=tf.UnconnectedGradients.NONE) -> Union[np.array, list]:
def __call__(
self,
score,
seed_input=None,
input_range=(0, 255),
input_modifiers=[Jitter(jitter=8), Rotate2D(degree=3)],
regularizers=[TotalVariation2D(weight=1.0),
Norm(weight=1.0, p=2)],
steps=200,
optimizer=None, # When None, the default is tf.optimizers.RMSprop(1.0, 0.999)
normalize_gradient=None, # Disabled option.
gradient_modifier=None,
callbacks=None,
training=False,
unconnected_gradients=tf.UnconnectedGradients.NONE) -> Union[np.array, list]:
"""Generate the model inputs that maximize the output of the given `score` functions.
Args:
Expand Down
4 changes: 2 additions & 2 deletions tf_keras_vis/gradcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from scipy.ndimage.interpolation import zoom
from tensorflow.python.keras.layers.convolutional import Conv

from tf_keras_vis import ModelVisualization
from tf_keras_vis.utils import find_layer, is_mixed_precision, standardize, zoom_factor
from . import ModelVisualization
from .utils import find_layer, is_mixed_precision, standardize, zoom_factor

if version(tf.version.VERSION) >= version("2.4.0"):
from tensorflow.keras.mixed_precision import LossScaleOptimizer
Expand Down
4 changes: 2 additions & 2 deletions tf_keras_vis/gradcam_plus_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from packaging.version import parse as version
from scipy.ndimage.interpolation import zoom

from tf_keras_vis.gradcam import Gradcam
from tf_keras_vis.utils import is_mixed_precision, standardize, zoom_factor
from .gradcam import Gradcam
from .utils import is_mixed_precision, standardize, zoom_factor

if version(tf.version.VERSION) >= version("2.4.0"):
from tensorflow.keras.mixed_precision import LossScaleOptimizer
Expand Down
4 changes: 2 additions & 2 deletions tf_keras_vis/saliency.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import tensorflow.keras.backend as K
from packaging.version import parse as version

from tf_keras_vis import ModelVisualization
from tf_keras_vis.utils import get_num_of_steps_allowed, is_mixed_precision, listify, standardize
from . import ModelVisualization
from .utils import get_num_of_steps_allowed, is_mixed_precision, listify, standardize

if version(tf.version.VERSION) >= version("2.4.0"):
from tensorflow.keras.mixed_precision import LossScaleOptimizer
Expand Down
5 changes: 2 additions & 3 deletions tf_keras_vis/scorecam.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
import tensorflow.keras.backend as K
from scipy.ndimage.interpolation import zoom

from tf_keras_vis.gradcam import Gradcam
from tf_keras_vis.utils import (get_num_of_steps_allowed, is_mixed_precision, listify, standardize,
zoom_factor)
from .gradcam import Gradcam
from .utils import get_num_of_steps_allowed, is_mixed_precision, listify, standardize, zoom_factor


class Scorecam(Gradcam):
Expand Down
10 changes: 4 additions & 6 deletions tf_keras_vis/utils/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
'Please use `tf_keras_vis.activation_maximization.callbacks` instead.'),
DeprecationWarning)

from tf_keras_vis.activation_maximization.callbacks import \
Callback as OptimizerCallback # noqa: F401 E402 E501
from tf_keras_vis.activation_maximization.callbacks import GifGenerator2D # noqa: F401 E402
from tf_keras_vis.activation_maximization.callbacks import \
GifGenerator2D as GifGenerator # noqa: F401 E402
from tf_keras_vis.activation_maximization.callbacks import PrintLogger as Print # noqa: F401 E402
from ..activation_maximization.callbacks import Callback as OptimizerCallback # noqa: F401 E402
from ..activation_maximization.callbacks import GifGenerator2D # noqa: F401 E402
from ..activation_maximization.callbacks import GifGenerator2D as GifGenerator # noqa: F401 E402
from ..activation_maximization.callbacks import PrintLogger as Print # noqa: F401 E402
8 changes: 4 additions & 4 deletions tf_keras_vis/utils/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
warnings.warn(('`tf_keras_vis.utils.losses` module is deprecated. '
'Please use `tf_keras_vis.utils.scores` instead.'), DeprecationWarning)

from tf_keras_vis.utils.scores import BinaryScore as BinaryLoss # noqa: F401 E402
from tf_keras_vis.utils.scores import CategoricalScore as CategoricalLoss # noqa: F401 E402
from tf_keras_vis.utils.scores import InactiveScore as InactiveLoss # noqa: F401 E402
from tf_keras_vis.utils.scores import Score as Loss # noqa: F401 E402
from .scores import BinaryScore as BinaryLoss # noqa: F401 E402
from .scores import CategoricalScore as CategoricalLoss # noqa: F401 E402
from .scores import InactiveScore as InactiveLoss # noqa: F401 E402
from .scores import Score as Loss # noqa: F401 E402
2 changes: 1 addition & 1 deletion tf_keras_vis/utils/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import tensorflow as tf

from tf_keras_vis.utils import listify
from . import listify


class Score(ABC):
Expand Down
8 changes: 4 additions & 4 deletions tf_keras_vis/utils/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from tensorflow.keras.layers import Conv2D, Dense, GlobalAveragePooling2D, Input
from tensorflow.keras.models import Model

from tf_keras_vis.activation_maximization.callbacks import Callback
from tf_keras_vis.utils.input_modifiers import InputModifier
from tf_keras_vis.utils.regularizers import Regularizer
from tf_keras_vis.utils.scores import Score
from ..activation_maximization.callbacks import Callback
from ..activation_maximization.input_modifiers import InputModifier
from ..activation_maximization.regularizers import Regularizer
from .scores import Score


def mock_dense_model():
Expand Down

0 comments on commit 020c199

Please sign in to comment.