Skip to content

Commit

Permalink
Merge pull request #94 from keisen/issues/invalid-argument-type-for-c…
Browse files Browse the repository at this point in the history
…allbacks

Illegal argument type for callbacks
  • Loading branch information
keisen authored Nov 25, 2022
2 parents 5dbb10e + 27e253c commit 607a05a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ title: "tf-keras-vis"
repository: "https://github.com/keisen/tf-keras-vis"
url: "https://keisen.github.io/tf-keras-vis-docs/"
type: software
version: 0.8.3
date-released: "2022-11-24"
version: 0.8.4
date-released: "2022-11-25"
license-url: "https://github.com/keisen/tf-keras-vis/blob/master/LICENSE"
references:
- authors:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.3
0.8.4
6 changes: 3 additions & 3 deletions tf_keras_vis/activation_maximization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,10 @@ def _clip_and_modify(self, seed_inputs, input_ranges, activation_modifiers):
input_ranges = [(input_tensor.dtype.min if low is None else low,
input_tensor.dtype.max if high is None else high)
for (low, high), input_tensor in zip(input_ranges, self.model.inputs)]
clipped_values = (np.array(K.clip(X, low, high))
clipped_values = (K.clip(X, low, high)
for X, (low, high) in zip(seed_inputs, input_ranges))
clipped_values = (X.astype(np.int) if isinstance(t, int) else X.astype(np.float32)
for X, (t, _) in zip(clipped_values, input_ranges))
clipped_values = (tf.cast(X, input_tensor.dtype)
for X, input_tensor in zip(clipped_values, self.model.inputs))
if activation_modifiers is not None:
clipped_values = ((activation_modifiers[name], seed_input)
for name, seed_input in zip(self.model.input_names, clipped_values))
Expand Down
3 changes: 2 additions & 1 deletion tf_keras_vis/activation_maximization/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def __call__(self, i, values, *args, **kwargs) -> None:
if self.data is None:
self.data = [[] for _ in range(len(values))]
for n, value in enumerate(values):
img = Image.fromarray(value[0].astype(np.uint8)) # 1st image in the batch
value = value[0].numpy() if tf.is_tensor(value[0]) else value[0]
img = Image.fromarray(value.astype(np.uint8)) # 1st image in the batch
ImageDraw.Draw(img).text((10, 10), f"Step {i + 1}", font=ImageFont.load_default())
self.data[n].append(np.asarray(img))

Expand Down
2 changes: 1 addition & 1 deletion tf_keras_vis/saliency.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __call__(self,
# Processing saliency
if smooth_samples > 0:
smooth_samples = get_num_of_steps_allowed(smooth_samples)
seed_inputs = (tf.tile(X, (smooth_samples, ) + tuple(np.ones(X.ndim - 1, np.int)))
seed_inputs = (tf.tile(X, (smooth_samples, ) + tuple(np.ones(X.ndim - 1, np.int32)))
for X in seed_inputs)
seed_inputs = (tf.reshape(X, (smooth_samples, -1) + tuple(X.shape[1:]))
for X in seed_inputs)
Expand Down

0 comments on commit 607a05a

Please sign in to comment.