diff --git a/tensorflow_graphics/geometry/transformation/axis_angle.py b/tensorflow_graphics/geometry/transformation/axis_angle.py index 1352312af..6418bee08 100644 --- a/tensorflow_graphics/geometry/transformation/axis_angle.py +++ b/tensorflow_graphics/geometry/transformation/axis_angle.py @@ -73,7 +73,7 @@ def from_euler(angles: type_alias.TensorLike, `[A1, ..., An, 1]`, where the first tensor represents the axis, and the second represents the angle. The resulting axis is a normalized vector. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = quaternion_lib.from_euler(angles) return from_quaternion(quaternion) @@ -109,7 +109,7 @@ def from_euler_with_small_angles_approximation( `[A1, ..., An, 1]`, where the first tensor represents the axis, and the second represents the angle. The resulting axis is a normalized vector. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = quaternion_lib.from_euler_with_small_angles_approximation( angles) return from_quaternion(quaternion) @@ -136,7 +136,7 @@ def from_quaternion(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -180,7 +180,7 @@ def from_rotation_matrix(rotation_matrix: type_alias.TensorLike, Raises: ValueError: If the shape of `rotation_matrix` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): rotation_matrix = tf.convert_to_tensor(value=rotation_matrix) shape.check_static( @@ -218,7 +218,7 @@ def inverse(axis: type_alias.TensorLike, Raises: ValueError: If the shape of `axis` or `angle` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -256,7 +256,7 @@ def is_normalized(axis: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 1]`, where False indicates that the axis is not normalized. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -305,7 +305,7 @@ def rotate(point: type_alias.TensorLike, ValueError: If `point`, `axis`, or `angle` are of different shape or if their respective shape is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point = tf.convert_to_tensor(value=point) axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) diff --git a/tensorflow_graphics/geometry/transformation/dual_quaternion.py b/tensorflow_graphics/geometry/transformation/dual_quaternion.py index 3def34a78..39dc851cc 100644 --- a/tensorflow_graphics/geometry/transformation/dual_quaternion.py +++ b/tensorflow_graphics/geometry/transformation/dual_quaternion.py @@ -63,7 +63,7 @@ def conjugate(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual_quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -97,7 +97,7 @@ def multiply(dual_quaternion1: type_alias.TensorLike, Returns: A tensor of shape `[A1, ..., An, 8]` representing dual quaternions. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): dual_quaternion1 = tf.convert_to_tensor(value=dual_quaternion1) dual_quaternion2 = tf.convert_to_tensor(value=dual_quaternion2) @@ -144,7 +144,7 @@ def inverse(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -193,7 +193,7 @@ def norm(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -234,7 +234,7 @@ def is_normalized(dual_quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `dual_quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -278,7 +278,7 @@ def from_rotation_translation( Raises: ValueError: If the shape of `rotation_matrix` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): rotation_quaternion = tf.convert_to_tensor(value=rotation_quaternion) translation_vector = tf.convert_to_tensor(value=translation_vector) @@ -319,7 +319,7 @@ def to_rotation_translation( A tuple with a `[A1, ..., An, 4]`-tensor for rotation in quaternion form, and a `[A1, ..., An, 3]`-tensor for translation, in that order. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -362,7 +362,7 @@ def from_axis_angle_translation(axis: type_alias.TensorLike, ValueError: If the shape of `axis`, `angle`, or `translation_vector` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) translation_vector = tf.convert_to_tensor(value=translation_vector) @@ -415,7 +415,7 @@ def conjugate_dual( Raises: ValueError: If the shape of `dual_quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): dual_quaternion = tf.convert_to_tensor(value=dual_quaternion) shape.check_static( @@ -442,7 +442,7 @@ def point_to_dual_quaternion( Returns: The dual quaternion representation of `point`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point = tf.convert_to_tensor(value=point) shape.check_static( diff --git a/tensorflow_graphics/geometry/transformation/euler.py b/tensorflow_graphics/geometry/transformation/euler.py index c63bf40aa..4b406b4fd 100644 --- a/tensorflow_graphics/geometry/transformation/euler.py +++ b/tensorflow_graphics/geometry/transformation/euler.py @@ -60,7 +60,7 @@ def from_axis_angle(axis: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 3]`, where the last dimension represents the three Euler angles. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): return from_quaternion(quaternion.from_axis_angle(axis, angle)) @@ -98,7 +98,7 @@ def gimbal_lock(r01, r02, r20, eps_addition): angles = tf.stack((theta_x, theta_y, theta_z), axis=-1) return angles - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternions = tf.convert_to_tensor(value=quaternions) shape.check_static( @@ -193,7 +193,7 @@ def gimbal_lock(rotation_matrix, r20, eps_addition): angles = tf.stack((theta_x, theta_y, theta_z), axis=-1) return angles - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): rotation_matrix = tf.convert_to_tensor(value=rotation_matrix) shape.check_static( @@ -232,7 +232,7 @@ def inverse(euler_angle: type_alias.TensorLike, Raises: ValueError: If the shape of `euler_angle` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): euler_angle = tf.convert_to_tensor(value=euler_angle) shape.check_static( diff --git a/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py b/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py index 8ceb3e91b..58870a6d7 100644 --- a/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py +++ b/tensorflow_graphics/geometry/transformation/linear_blend_skinning.py @@ -56,7 +56,7 @@ def blend(points: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): points = tf.convert_to_tensor(value=points) skinning_weights = tf.convert_to_tensor(value=skinning_weights) bone_rotations = tf.convert_to_tensor(value=bone_rotations) diff --git a/tensorflow_graphics/geometry/transformation/look_at.py b/tensorflow_graphics/geometry/transformation/look_at.py index 42d8fa526..91f7267ed 100644 --- a/tensorflow_graphics/geometry/transformation/look_at.py +++ b/tensorflow_graphics/geometry/transformation/look_at.py @@ -50,7 +50,7 @@ def right_handed(camera_position: type_alias.TensorLike, A tensor of shape `[A1, ..., An, 4, 4]`, containing right handed look at matrices. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): camera_position = tf.convert_to_tensor(value=camera_position) look_at = tf.convert_to_tensor(value=look_at) up_vector = tf.convert_to_tensor(value=up_vector) diff --git a/tensorflow_graphics/geometry/transformation/quaternion.py b/tensorflow_graphics/geometry/transformation/quaternion.py index e7fa4f3ea..abb02c83d 100644 --- a/tensorflow_graphics/geometry/transformation/quaternion.py +++ b/tensorflow_graphics/geometry/transformation/quaternion.py @@ -98,7 +98,7 @@ def between_two_vectors_3d(vector1: type_alias.TensorLike, Raises: ValueError: If the shape of `vector1` or `vector2` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) @@ -154,7 +154,7 @@ def conjugate(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -187,7 +187,7 @@ def from_axis_angle(axis: type_alias.TensorLike, Raises: ValueError: If the shape of `axis` or `angle` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -229,7 +229,7 @@ def from_euler(angles: type_alias.TensorLike, Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -272,7 +272,7 @@ def from_euler_with_small_angles_approximation( Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -310,7 +310,7 @@ def from_rotation_matrix(rotation_matrix: type_alias.TensorLike, Raises: ValueError: If the shape of `rotation_matrix` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): rotation_matrix = tf.convert_to_tensor(value=rotation_matrix) shape.check_static( @@ -395,7 +395,7 @@ def inverse(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -429,7 +429,7 @@ def is_normalized(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -463,7 +463,7 @@ def normalize(quaternion: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -494,7 +494,7 @@ def multiply(quaternion1: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion1` or `quaternion2` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion1 = tf.convert_to_tensor(value=quaternion1) quaternion2 = tf.convert_to_tensor(value=quaternion2) @@ -526,7 +526,7 @@ def normalized_random_uniform(quaternion_shape: List[int], A tensor of shape `[quaternion_shape[0],...,quaternion_shape[-1], 4]` representing random normalized quaternions. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion_shape = tf.convert_to_tensor( value=quaternion_shape, dtype=tf.int32) quaternion_shape = tf.concat((quaternion_shape, tf.constant([4])), axis=0) @@ -594,7 +594,7 @@ def rotate(point: type_alias.TensorLike, Raises: ValueError: If the shape of `point` or `quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point = tf.convert_to_tensor(value=point) quaternion = tf.convert_to_tensor(value=quaternion) @@ -642,7 +642,7 @@ def relative_angle(quaternion1: type_alias.TensorLike, Raises: ValueError: If the shape of `quaternion1` or `quaternion2` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion1 = tf.convert_to_tensor(value=quaternion1) quaternion2 = tf.convert_to_tensor(value=quaternion2) diff --git a/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py b/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py index 6a0aa37a3..e572427eb 100644 --- a/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py +++ b/tensorflow_graphics/geometry/transformation/rotation_matrix_2d.py @@ -77,7 +77,7 @@ def from_euler(angle: type_alias.TensorLike, Raises: ValueError: If the shape of `angle` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): angle = tf.convert_to_tensor(value=angle) shape.check_static( @@ -132,7 +132,7 @@ def from_euler_with_small_angles_approximation( Raises: ValueError: If the shape of `angle` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -166,7 +166,7 @@ def inverse(matrix: type_alias.TensorLike, Raises: ValueError: If the shape of `matrix` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -201,7 +201,7 @@ def is_valid(matrix: type_alias.TensorLike, A tensor of type `bool` and shape `[A1, ..., An, 1]` where False indicates that the input is not a valid rotation matrix. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -236,7 +236,7 @@ def rotate(point: type_alias.TensorLike, Raises: ValueError: If the shape of `point` or `matrix` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point = tf.convert_to_tensor(value=point) matrix = tf.convert_to_tensor(value=matrix) diff --git a/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py b/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py index 50908ca67..8cb9dfb8a 100644 --- a/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py +++ b/tensorflow_graphics/geometry/transformation/rotation_matrix_3d.py @@ -99,7 +99,7 @@ def assert_rotation_matrix_normalized( if not FLAGS[tfg_flags.TFG_ADD_ASSERTS_TO_GRAPH].value: return matrix - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -142,7 +142,7 @@ def from_axis_angle( Raises: ValueError: If the shape of `axis` or `angle` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): axis = tf.convert_to_tensor(value=axis) angle = tf.convert_to_tensor(value=angle) @@ -204,7 +204,7 @@ def from_euler(angles: type_alias.TensorLike, Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -244,7 +244,7 @@ def from_euler_with_small_angles_approximation( Raises: ValueError: If the shape of `angles` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): angles = tf.convert_to_tensor(value=angles) shape.check_static( @@ -276,7 +276,7 @@ def from_quaternion( Raises: ValueError: If the shape of `quaternion` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): quaternion = tf.convert_to_tensor(value=quaternion) shape.check_static( @@ -323,7 +323,7 @@ def inverse(matrix: type_alias.TensorLike, Raises: ValueError: If the shape of `matrix` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -356,7 +356,7 @@ def is_valid(matrix: type_alias.TensorLike, A tensor of type `bool` and shape `[A1, ..., An, 1]` where False indicates that the input is not a valid rotation matrix. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matrix = tf.convert_to_tensor(value=matrix) shape.check_static( @@ -392,7 +392,7 @@ def rotate(point: type_alias.TensorLike, ValueError: If the shape of `point` or `rotation_matrix_3d` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point = tf.convert_to_tensor(value=point) matrix = tf.convert_to_tensor(value=matrix) diff --git a/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py b/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py index 185d58677..41998bb1c 100644 --- a/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py +++ b/tensorflow_graphics/geometry/transformation/rotation_matrix_common.py @@ -45,7 +45,7 @@ def is_valid(matrix: type_alias.TensorLike, A tensor of type `bool` and shape `[A1, ..., An, 1]` where False indicates that the input is not a valid rotation matrix. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): matrix = tf.convert_to_tensor(value=matrix) shape.check_static( diff --git a/tensorflow_graphics/math/feature_representation.py b/tensorflow_graphics/math/feature_representation.py index 35b9cf858..a0cda9b00 100644 --- a/tensorflow_graphics/math/feature_representation.py +++ b/tensorflow_graphics/math/feature_representation.py @@ -37,7 +37,7 @@ def positional_encoding(features: TensorLike, Returns: A tensor of shape `[A1, ..., An, 2*N*M + M]`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): features = tf.convert_to_tensor(value=features) output = [features] diff --git a/tensorflow_graphics/math/math_helpers.py b/tensorflow_graphics/math/math_helpers.py index a58e2d913..9976511f4 100644 --- a/tensorflow_graphics/math/math_helpers.py +++ b/tensorflow_graphics/math/math_helpers.py @@ -52,7 +52,7 @@ def cartesian_to_spherical_coordinates( (`r`,`theta`,`phi`), where `r` is the sphere radius, `theta` is the polar angle and `phi` is the azimuthal angle. Returns `NaN` gradient if x = y = 0. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_cartesian = tf.convert_to_tensor(value=point_cartesian) shape.check_static( @@ -140,7 +140,7 @@ def spherical_to_cartesian_coordinates( A tensor of shape `[A1, ..., An, 3]`, where the last dimension contains the cartesian coordinates in x,y,z order. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_spherical = tf.convert_to_tensor(value=point_spherical) shape.check_static( @@ -180,7 +180,7 @@ def square_to_spherical_coordinates( [0,1]. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): point_2d = tf.convert_to_tensor(value=point_2d) shape.check_static( diff --git a/tensorflow_graphics/math/sampling.py b/tensorflow_graphics/math/sampling.py index 0a0a067c0..e89553f00 100644 --- a/tensorflow_graphics/math/sampling.py +++ b/tensorflow_graphics/math/sampling.py @@ -40,7 +40,7 @@ def regular_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -70,7 +70,7 @@ def regular_inverse_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -100,7 +100,7 @@ def uniform_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -135,7 +135,7 @@ def stratified_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -175,7 +175,7 @@ def logspace_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) shape.compare_batch_dimensions( @@ -209,7 +209,7 @@ def geomspace_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) shape.compare_batch_dimensions( @@ -238,7 +238,7 @@ def stratified_geomspace_1d(near: TensorLike, Returns: A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): near = tf.convert_to_tensor(near) far = tf.convert_to_tensor(far) @@ -268,7 +268,7 @@ def _normalize_pdf(pdf: TensorLike, name="normalize_pdf") -> tf.Tensor: Returns: A tensor of shape `[A1, ..., An, M]`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): pdf = tf.convert_to_tensor(value=pdf) pdf += 1e-5 return safe_ops.safe_signed_div(pdf, tf.reduce_sum(pdf, -1, keepdims=True)) @@ -285,7 +285,7 @@ def _get_cdf(pdf: TensorLike, name="get_cdf"): Returns: A tensor of shape `[A1, ..., An, M+1]`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): pdf = tf.convert_to_tensor(value=pdf) batch_shape = tf.shape(pdf)[:-1] cdf = tf.cumsum(pdf, -1) @@ -317,7 +317,7 @@ def inverse_transform_sampling_1d( A tensor of shape `[A1, ..., An, N]` indicating the new N random points. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): bins = tf.convert_to_tensor(value=bins) pdf = tf.convert_to_tensor(value=pdf) @@ -378,7 +378,7 @@ def inverse_transform_stratified_1d(bin_start: TensorLike, A tensor of shape `[A1, ..., An, N]` indicating the N points on the ray """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): bin_start = tf.convert_to_tensor(value=bin_start) bin_width = tf.convert_to_tensor(value=bin_width) pdf = tf.convert_to_tensor(value=pdf) diff --git a/tensorflow_graphics/math/spherical_harmonics.py b/tensorflow_graphics/math/spherical_harmonics.py index 19fd1a74b..39db7601b 100644 --- a/tensorflow_graphics/math/spherical_harmonics.py +++ b/tensorflow_graphics/math/spherical_harmonics.py @@ -58,7 +58,7 @@ def integration_product( ValueError: if the last dimension of `harmonics1` is different from the last dimension of `harmonics2`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): harmonics1 = tf.convert_to_tensor(value=harmonics1) harmonics2 = tf.convert_to_tensor(value=harmonics2) @@ -88,7 +88,7 @@ def generate_l_m_permutations( Returns: Two tensors of shape `[max_band*max_band]`. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): degree_l = [] order_m = [] for degree in range(0, max_band + 1): @@ -112,7 +112,7 @@ def generate_l_m_zonal( Returns: Two tensors of shape `[max_band+1]`, one for degree l and one for order m. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): degree_l = np.linspace(0, max_band, num=max_band + 1, dtype=np.int32) order_m = np.zeros(max_band + 1, dtype=np.int32) return (tf.convert_to_tensor(value=degree_l), @@ -273,7 +273,7 @@ def evaluate_spherical_harmonics( InvalidArgumentError: if at least an element of `l`, `m`, `theta` or `phi` is outside the expected range. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): degree_l = tf.convert_to_tensor(value=degree_l) order_m = tf.convert_to_tensor(value=order_m) theta = tf.convert_to_tensor(value=theta) @@ -339,7 +339,7 @@ def rotate_zonal_harmonics( ValueError: If the shape of `zonal_coeffs`, `theta` or `phi` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): zonal_coeffs = tf.convert_to_tensor(value=zonal_coeffs) theta = tf.convert_to_tensor(value=theta) phi = tf.convert_to_tensor(value=phi) @@ -386,7 +386,7 @@ def tile_zonal_coefficients( Raises: ValueError: if the shape of `coefficients` is not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): coefficients = tf.convert_to_tensor(value=coefficients) shape.check_static( diff --git a/tensorflow_graphics/math/vector.py b/tensorflow_graphics/math/vector.py index d59656045..c275b9b2e 100644 --- a/tensorflow_graphics/math/vector.py +++ b/tensorflow_graphics/math/vector.py @@ -47,7 +47,7 @@ def cross(vector1: TensorLike, A tensor of shape `[A1, ..., Ai = 3, ..., An]`, where the dimension i = axis represents the result of the cross product. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) @@ -90,7 +90,7 @@ def dot(vector1: TensorLike, A tensor of shape `[A1, ..., Ai = 1, ..., An]`, where the dimension i = axis represents the result of the dot product. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector1 = tf.convert_to_tensor(value=vector1) vector2 = tf.convert_to_tensor(value=vector2) @@ -132,7 +132,7 @@ def reflect(vector: TensorLike, A tensor of shape `[A1, ..., Ai, ..., An]`, where the dimension i = axis represents a reflected vector. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): vector = tf.convert_to_tensor(value=vector) normal = tf.convert_to_tensor(value=normal) diff --git a/tensorflow_graphics/projects/gan/architectures_progressive_gan.py b/tensorflow_graphics/projects/gan/architectures_progressive_gan.py index 217025f34..85c73984f 100644 --- a/tensorflow_graphics/projects/gan/architectures_progressive_gan.py +++ b/tensorflow_graphics/projects/gan/architectures_progressive_gan.py @@ -103,7 +103,7 @@ def create_generator(latent_code_dimension: int = 128, The created generator keras model object. """ if kernel_initializer is None: - kernel_initializer = tf.keras.initializers.TruncatedNormal( # pyrefly: ignore[bad-assignment] + kernel_initializer = tf.keras.initializers.TruncatedNormal( mean=0.0, stddev=1.0) input_tensor = tf.keras.Input(shape=(latent_code_dimension,)) @@ -118,9 +118,9 @@ def create_generator(latent_code_dimension: int = 128, units=4 * 4 * latent_code_dimension, kernel_initializer=kernel_initializer)( maybe_normzlized_input_tensor) - tensor = tf.keras.layers.Reshape(target_shape=(4, 4, latent_code_dimension))( # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.Reshape(target_shape=(4, 4, latent_code_dimension))( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_batch_normalization: tensor = tf.keras.layers.BatchNormalization()(tensor) if use_pixel_normalization: @@ -132,7 +132,7 @@ def create_generator(latent_code_dimension: int = 128, padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_batch_normalization: tensor = tf.keras.layers.BatchNormalization()(tensor) if use_pixel_normalization: @@ -144,7 +144,7 @@ def create_generator(latent_code_dimension: int = 128, outputs.append( to_rgb( input_tensor=tensor, - kernel_initializer=kernel_initializer, # pyrefly: ignore[bad-argument-type] + kernel_initializer=kernel_initializer, name='side_output_%d_conv' % index)) tensor = keras_layers.TwoByTwoNearestNeighborUpSampling()(tensor) @@ -156,7 +156,7 @@ def create_generator(latent_code_dimension: int = 128, padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_batch_normalization: tensor = tf.keras.layers.BatchNormalization()(tensor) if use_pixel_normalization: @@ -164,7 +164,7 @@ def create_generator(latent_code_dimension: int = 128, tensor = to_rgb( input_tensor=tensor, - kernel_initializer=kernel_initializer, # pyrefly: ignore[bad-argument-type] + kernel_initializer=kernel_initializer, name='final_output') if generate_intermediate_outputs: outputs.append(tensor) @@ -213,7 +213,7 @@ def from_rgb(input_tensor: tf.Tensor, Returns: The feature map. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): output = create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernel, filters=num_channels, @@ -222,7 +222,7 @@ def from_rgb(input_tensor: tf.Tensor, kernel_initializer=kernel_initializer, padding='same')( input_tensor) - return tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(output) # pyrefly: ignore[not-callable] + return tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(output) def create_discriminator( @@ -270,7 +270,7 @@ def create_discriminator( The generated discriminator keras model. """ if kernel_initializer is None: - kernel_initializer = tf.keras.initializers.TruncatedNormal( # pyrefly: ignore[bad-assignment] + kernel_initializer = tf.keras.initializers.TruncatedNormal( mean=0.0, stddev=1.0) if use_intermediate_inputs: @@ -286,7 +286,7 @@ def create_discriminator( tensor, use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, num_channels=downsampling_blocks_num_channels[0][0], - kernel_initializer=kernel_initializer, # pyrefly: ignore[bad-argument-type] + kernel_initializer=kernel_initializer, relu_leakiness=relu_leakiness) if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) @@ -301,7 +301,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) tensor = create_conv_layer( @@ -312,7 +312,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) if use_antialiased_bilinear_downsampling: @@ -330,7 +330,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) @@ -342,7 +342,7 @@ def create_discriminator( padding='valid', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_layer_normalization: tensor = tfa_normalizations.GroupNormalization(groups=1)(tensor) @@ -353,7 +353,7 @@ def create_discriminator( kernel_size=1, kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.Reshape((-1,))(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.Reshape((-1,))(tensor) if use_intermediate_inputs: return tf.keras.Model(inputs=inputs, outputs=tensor, name=name) # pyrefly: ignore[unbound-name] diff --git a/tensorflow_graphics/projects/gan/architectures_style_gan.py b/tensorflow_graphics/projects/gan/architectures_style_gan.py index a6a53ac79..81c8d9627 100644 --- a/tensorflow_graphics/projects/gan/architectures_style_gan.py +++ b/tensorflow_graphics/projects/gan/architectures_style_gan.py @@ -113,7 +113,7 @@ def create_mapping_network(latent_code_dimension: int = 128, tensor = maybe_normalized_input_tensor for i in range(num_layers): - with tf.name_scope(name='mapping_layer_%d' % i): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name='mapping_layer_%d' % i): # The kernel_multiplier implements the reduced learning rate of the # mapping network. tensor = keras_layers.FanInScaledDense( @@ -123,7 +123,7 @@ def create_mapping_network(latent_code_dimension: int = 128, kernel_initializer=tf.keras.initializers.TruncatedNormal( mean=0.0, stddev=1.0 / learning_rate_multiplier))( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) return tf.keras.Model(inputs=input_tensor, outputs=tensor, name=name) @@ -162,7 +162,7 @@ def create_synthesis_network(latent_code_dimension: int = 128, tensor = keras_layers.LearnedConstant()(mapped_latent_code_input) tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) tensor = apply_style_with_adain( mapped_latent_code=mapped_latent_code_input, input_tensor=tensor) tensor = keras_layers.FanInScaledConv2D( @@ -173,7 +173,7 @@ def create_synthesis_network(latent_code_dimension: int = 128, kernel_initializer=kernel_initializer)( tensor) tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) tensor = apply_style_with_adain( mapped_latent_code=mapped_latent_code_input, input_tensor=tensor) @@ -197,7 +197,7 @@ def create_synthesis_network(latent_code_dimension: int = 128, kernel_initializer=kernel_initializer)( tensor) tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) tensor = apply_style_with_adain( mapped_latent_code=mapped_latent_code_input, input_tensor=tensor) @@ -262,8 +262,8 @@ def create_style_based_generator( use_bilinear_upsampling=use_bilinear_upsampling) input_tensor = tf.keras.Input(shape=(latent_code_dimension,)) - mapped_latent_code = mapping_network(input_tensor) # pyrefly: ignore[not-callable] - generated_images = synthesis_network(mapped_latent_code) # pyrefly: ignore[not-callable] + mapped_latent_code = mapping_network(input_tensor) + generated_images = synthesis_network(mapped_latent_code) generator = tf.keras.Model( inputs=input_tensor, outputs=generated_images, name=name) diff --git a/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py b/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py index 64a2735df..4a97e4067 100644 --- a/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py +++ b/tensorflow_graphics/projects/gan/architectures_style_gan_v2.py @@ -135,7 +135,7 @@ def create_synthesis_network( tensor = keras_layers.Noise()((tensor, noise_inputs[0])) # pyrefly: ignore[unbound-name] else: tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) output = None for index, channels in enumerate(upsampling_blocks_num_channels): @@ -157,7 +157,7 @@ def create_synthesis_network( tensor = keras_layers.Noise()((tensor, noise_inputs[noise_index])) else: tensor = keras_layers.Noise()(tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) output = _maybe_upsample_and_add_outputs( architectures_progressive_gan.to_rgb( @@ -270,7 +270,7 @@ def create_discriminator( The generated discriminator keras model. """ if kernel_initializer is None: - kernel_initializer = tf.keras.initializers.TruncatedNormal( # pyrefly: ignore[bad-assignment] + kernel_initializer = tf.keras.initializers.TruncatedNormal( mean=0.0, stddev=1.0) input_tensor = tf.keras.Input(shape=(None, None, num_channels)) @@ -283,7 +283,7 @@ def create_discriminator( for index, (channels_1, channels_2) in enumerate(downsampling_blocks_num_channels): - with tf.name_scope(f'downsampling_block_{index}'): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(f'downsampling_block_{index}'): shortcut = tensor shortcut = architectures_progressive_gan.create_conv_layer( @@ -306,7 +306,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) tensor = architectures_progressive_gan.create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, filters=channels_2, @@ -315,7 +315,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) if use_antialiased_bilinear_downsampling: tensor = keras_layers.Blur2D()(tensor) tensor = tf.keras.layers.AveragePooling2D()(tensor) @@ -331,7 +331,7 @@ def create_discriminator( padding='same', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) tensor = architectures_progressive_gan.create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, @@ -341,7 +341,7 @@ def create_discriminator( padding='valid', kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.LeakyReLU(alpha=relu_leakiness)(tensor) tensor = architectures_progressive_gan.create_conv_layer( use_fan_in_scaled_kernel=use_fan_in_scaled_kernels, @@ -350,6 +350,6 @@ def create_discriminator( kernel_size=1, kernel_initializer=kernel_initializer)( tensor) - tensor = tf.keras.layers.Reshape((-1,))(tensor) # pyrefly: ignore[not-callable] + tensor = tf.keras.layers.Reshape((-1,))(tensor) return tf.keras.Model(inputs=input_tensor, outputs=tensor, name=name) diff --git a/tensorflow_graphics/projects/gan/exponential_moving_average.py b/tensorflow_graphics/projects/gan/exponential_moving_average.py index fc8327807..0a662ca75 100644 --- a/tensorflow_graphics/projects/gan/exponential_moving_average.py +++ b/tensorflow_graphics/projects/gan/exponential_moving_average.py @@ -51,7 +51,7 @@ def __init__(self, decay: float = 0.999): def _ema_assign_fn(self, variable: tf.Variable, value: tf.Tensor): """Updates the exponential moving average for a single variable.""" - return variable.assign(self._decay * variable + (1.0 - self._decay) * value) # pyrefly: ignore[unsupported-operation] + return variable.assign(self._decay * variable + (1.0 - self._decay) * value) def _apply_values(self, variables: Sequence[tf.Variable]): """Applies the new values to the exponential moving averages.""" diff --git a/tensorflow_graphics/projects/gan/keras_layers.py b/tensorflow_graphics/projects/gan/keras_layers.py index ee7630a64..e143cda95 100644 --- a/tensorflow_graphics/projects/gan/keras_layers.py +++ b/tensorflow_graphics/projects/gan/keras_layers.py @@ -88,7 +88,7 @@ def kernel(self) -> tf.Tensor: # Fan in computation assumes that the last dimension of the kernel is the # output dimension. fan_in = np.prod(self._kernel.shape.as_list()[:-1]) - return (self._kernel * self._multiplier / math.sqrt(fan_in) * # pyrefly: ignore[bad-return, unsupported-operation] + return (self._kernel * self._multiplier / math.sqrt(fan_in) * self._kernel_multiplier) @kernel.setter @@ -98,7 +98,7 @@ def kernel(self, kernel: tf.Variable) -> None: @property def bias(self) -> tf.Tensor: if self._bias_multiplier is not None: - return self._bias * self._bias_multiplier # pyrefly: ignore[bad-return, unsupported-operation] + return self._bias * self._bias_multiplier else: return self._bias.read_value() @@ -384,7 +384,7 @@ def call( raise ValueError('inputs needs to have two elements.') feature_map, mapped_latent_code = inputs - style = self._dense_layer(mapped_latent_code)[:, tf.newaxis, tf.newaxis, :] # pyrefly: ignore[not-callable] + style = self._dense_layer(mapped_latent_code)[:, tf.newaxis, tf.newaxis, :] modulated_features = self._conv_layer(feature_map * style) weight = self._conv_layer.kernel[tf.newaxis, :, :, :, :] diff --git a/tensorflow_graphics/projects/gan/losses.py b/tensorflow_graphics/projects/gan/losses.py index 28808c162..ff518414c 100644 --- a/tensorflow_graphics/projects/gan/losses.py +++ b/tensorflow_graphics/projects/gan/losses.py @@ -54,7 +54,7 @@ def gradient_penalty_loss(real_data: Union[tf.Tensor, Sequence[tf.Tensor]], ValueError if the numnber of elements in real_data and generated_data are not equal. """ - with tf.name_scope(name=name_scope): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name=name_scope): with tf.GradientTape() as tape: if (isinstance(real_data, tf.Tensor) and isinstance(generated_data, tf.Tensor)): @@ -88,9 +88,9 @@ def gradient_penalty_loss(real_data: Union[tf.Tensor, Sequence[tf.Tensor]], (type(real_data), type(generated_data))) # By default the gradient tape only watches trainable variables. tape.watch(interpolated_data) - interpolated_labels = discriminator(interpolated_data) # pyrefly: ignore[not-callable] + interpolated_labels = discriminator(interpolated_data) - with tf.name_scope(name='gradients'): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name='gradients'): gradients = tape.gradient( target=interpolated_labels, sources=interpolated_data) @@ -146,12 +146,12 @@ def r1_regularization(real_data: Union[tf.Tensor, Sequence[tf.Tensor]], Returns: The r1 regulatization loss per example as tensor of shape [batch_size]. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): with tf.GradientTape() as tape: tape.watch(real_data) - discriminator_output = discriminator(real_data) # pyrefly: ignore[not-callable] + discriminator_output = discriminator(real_data) - with tf.name_scope(name='gradients'): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name='gradients'): gradients = tape.gradient( target=discriminator_output, sources=real_data) @@ -186,7 +186,7 @@ def wasserstein_generator_loss( Returns: The loss for the generator. """ - with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name=name): return -discriminator_output_generated_data @@ -211,8 +211,8 @@ def wasserstein_discriminator_loss( Returns: The loss for the discriminator. """ - with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] - return discriminator_output_generated_data - discriminator_output_real_data # pyrefly: ignore[unsupported-operation] + with tf.name_scope(name=name): + return discriminator_output_generated_data - discriminator_output_real_data def wasserstein_hinge_generator_loss( @@ -235,7 +235,7 @@ def wasserstein_hinge_generator_loss( Returns: The loss for the generator. """ - with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name=name): return -discriminator_output_generated_data @@ -260,9 +260,9 @@ def wasserstein_hinge_discriminator_loss( Returns: The loss for the discriminator. """ - with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] - return tf.nn.relu(1.0 - discriminator_output_real_data) + tf.nn.relu( # pyrefly: ignore[unsupported-operation] - discriminator_output_generated_data + 1.0) # pyrefly: ignore[unsupported-operation] + with tf.name_scope(name=name): + return tf.nn.relu(1.0 - discriminator_output_real_data) + tf.nn.relu( + discriminator_output_generated_data + 1.0) def minimax_generator_loss(discriminator_output_generated_data: tf.Tensor, @@ -280,7 +280,7 @@ def minimax_generator_loss(discriminator_output_generated_data: tf.Tensor, Returns: The loss for the generator. """ - with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name=name): # -log(sigmoid(discriminator_output_generated_data)) return tf.nn.sigmoid_cross_entropy_with_logits( labels=tf.ones_like(discriminator_output_generated_data), @@ -306,7 +306,7 @@ def minimax_discriminator_loss( Returns: The loss for the discriminator. """ - with tf.name_scope(name=name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name=name): # -log(sigmoid(discriminator_output_real_data)) loss_real = tf.nn.sigmoid_cross_entropy_with_logits( labels=tf.ones_like(discriminator_output_real_data), diff --git a/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py b/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py index 5317b2e0d..da3336487 100644 --- a/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py +++ b/tensorflow_graphics/projects/gan/minibatch_standarddeviation.py @@ -141,7 +141,7 @@ class SyncMiniBatchStandardDeviation(MiniBatchStandardDeviationBase): def _calculate_mean_feature_standard_deviation(self, inputs, batch_axis): - with tf.name_scope('mean_feature_standard_deviation'): # pyrefly: ignore[bad-instantiation] + with tf.name_scope('mean_feature_standard_deviation'): # The dynamic range of fp16 is too limited to support the collection of # sufficient statistics. As a workaround we simply perform the operations # on 32-bit floats before converting the mean and variance back to fp16 diff --git a/tensorflow_graphics/rendering/volumetric/absorption.py b/tensorflow_graphics/rendering/volumetric/absorption.py index cc9bf4a62..32a53b56e 100644 --- a/tensorflow_graphics/rendering/volumetric/absorption.py +++ b/tensorflow_graphics/rendering/volumetric/absorption.py @@ -50,7 +50,7 @@ def render(voxels: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): voxels = tf.convert_to_tensor(value=voxels) shape.check_static( diff --git a/tensorflow_graphics/rendering/volumetric/emission_absorption.py b/tensorflow_graphics/rendering/volumetric/emission_absorption.py index e646c1c0b..23f4b8c8c 100644 --- a/tensorflow_graphics/rendering/volumetric/emission_absorption.py +++ b/tensorflow_graphics/rendering/volumetric/emission_absorption.py @@ -50,7 +50,7 @@ def render(voxels: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): voxels = tf.convert_to_tensor(value=voxels) shape.check_static( diff --git a/tensorflow_graphics/rendering/volumetric/ray_radiance.py b/tensorflow_graphics/rendering/volumetric/ray_radiance.py index cafc0ae8b..b04d9e2dd 100644 --- a/tensorflow_graphics/rendering/volumetric/ray_radiance.py +++ b/tensorflow_graphics/rendering/volumetric/ray_radiance.py @@ -47,7 +47,7 @@ def compute_radiance( and a tensor of shape `[A1, ..., An, N]` for the sample weights. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): rgba_values = tf.convert_to_tensor(value=rgba_values) distances = tf.convert_to_tensor(value=distances) distances = tf.expand_dims(distances, -1) diff --git a/tensorflow_graphics/rendering/volumetric/visual_hull.py b/tensorflow_graphics/rendering/volumetric/visual_hull.py index ed870621f..ec0328232 100644 --- a/tensorflow_graphics/rendering/volumetric/visual_hull.py +++ b/tensorflow_graphics/rendering/volumetric/visual_hull.py @@ -46,7 +46,7 @@ def render(voxels: type_alias.TensorLike, Raises: ValueError: If the shape of the input tensors are not supported. """ - with tf.name_scope(name): # pyrefly: ignore[bad-instantiation] + with tf.name_scope(name): voxels = tf.convert_to_tensor(value=voxels) shape.check_static(