Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit d80a1ce

Browse files
Updating some deprecated method parameters
1 parent 24c0b92 commit d80a1ce

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lucid/optvis/objectives.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def inner(T):
153153
shape = tf.shape(layer)
154154
x_ = shape[1] // 2 if x is None else x
155155
y_ = shape[2] // 2 if y is None else y
156-
156+
157157
if batch is None:
158158
return layer[:, x_, y_, channel_n]
159159
else:
@@ -199,7 +199,7 @@ def inner(T):
199199
def direction_cossim(layer, vec, batch=None):
200200
"""Visualize a direction (cossine similarity)"""
201201
def inner(T):
202-
act_mags = tf.sqrt(tf.reduce_sum(T(layer)**2, -1, keep_dims=True))
202+
act_mags = tf.sqrt(tf.reduce_sum(T(layer)**2, -1, keepdims=True))
203203
vec_mag = tf.sqrt(tf.reduce_sum(vec**2))
204204
mags = act_mags * vec_mag
205205
if batch is None:
@@ -411,7 +411,7 @@ def inner(T):
411411

412412
flattened = tf.reshape(layer_t, [batch_n, -1, channels])
413413
grams = tf.matmul(flattened, flattened, transpose_a=True)
414-
grams = tf.nn.l2_normalize(grams, dim=[1,2], epsilon=1e-10)
414+
grams = tf.nn.l2_normalize(grams, axis=[1,2], epsilon=1e-10)
415415

416416
return sum([ sum([ tf.reduce_sum(grams[i]*grams[j])
417417
for j in range(batch_n) if j != i])

lucid/optvis/transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def normalize_gradient(grad_scales=None):
9292
op_name = "NormalizeGrad_" + str(uuid.uuid4())
9393
@tf.RegisterGradient(op_name)
9494
def _NormalizeGrad(op, grad):
95-
grad_norm = tf.sqrt(tf.reduce_sum(grad**2, [1, 2, 3], keep_dims=True))
95+
grad_norm = tf.sqrt(tf.reduce_sum(grad**2, [1, 2, 3], keepdims=True))
9696
if grad_scales is not None:
9797
grad *= grad_scales[:, None, None, None]
9898
return grad / grad_norm

0 commit comments

Comments
 (0)