0

Here is the code which I want to use in my code but I am getting error ( AttributeError: Exception encountered when calling layer "zReLU1" (type zReLU). ) which I attached in a picture!!! Can anyone help?

def get_angle(self, x):
    real = self.get_realpart(x)
    imag = self.get_imagpart(x)
    comp = tf.complex(real, imag)
    ang = tf.math.angle(comp).numpy()
    return ang
    # T.angle(comp_num)


def call(self, x):

    real = self.get_realpart(x)
    imag = self.get_imagpart(x)
    # mag = self.get_abs(x)
    ang = self.get_angle(x) + 0.0001
    indices1 = T.nonzero(T.ge(ang, pi / 2))
    indices2 = T.nonzero(T.le(ang, 0))

    real = T.set_subtensor(real[indices1], 0)
    imag = T.set_subtensor(imag[indices1], 0)

    real = T.set_subtensor(real[indices2], 0)
    imag = T.set_subtensor(imag[indices2], 0)

    act = K.concatenate([real, imag], axis=1)

    return act


def compute_output_shape(self, input_shape):
    return input_shape

enter image description here

0

1 Answer 1

0

You can convert conjugate numbers to radius degrees and extract magnitude and imagination for longitude references.

Sample : The glob is round shape, peeling orange in the same way you locate the pieces of juices without a renewable all process.

import tensorflow as tf

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
None
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
config = tf.config.experimental.set_memory_growth(physical_devices[0], True)
print(physical_devices)
print(config)

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
: Variables
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
global real
real = tf.linspace([0., 5.], [10., 40.], 5, axis=-1)
imag = tf.linspace([0., 5.], [10., 40.], 5, axis=-1)

### Create complex number matrix ###
complex_number = tf.dtypes.complex(
    real, imag, name="Complex number"
)
print( "complex_number: " )
print( complex_number )

### Convert conjugate into degree radious ###
ang = tf.math.angle( complex_number ).numpy()
print( "ang: " )
print( ang )

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
: Functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
def get_angle( matrix ):
    
    ### -------------------------------------------- ###
    ### -X------------------------------------------ ###
    ### --X----------------------------------------- ###
    ### ---X---------------------------------------- ###
    ### ----X--------------------------------------- ###
    ### -------------------------------------------- ###
    
    real_matrix = tf.linspace([0., 0.], [0., 0.], 5, axis=-1)
    imag_matrix = tf.linspace([-1., -1.], [-1., -1.], 5, axis=-1)
    reverse_conjugate = tf.dtypes.complex(
        real_matrix, imag_matrix, name="Reverse_conjugate"
    )
    print( "reverse_conjugate: " )
    print( reverse_conjugate )
    
    angle_matrix = tf.math.multiply(
    reverse_conjugate, matrix , name="magnitude matrix"
    )
    print( "angle_matrix: " )
    print( angle_matrix )
    print( "magnitude_matrix: " )
    print( tf.math.add( angle_matrix, matrix ) )
    
    return

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
: Working
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
get_angle( complex_number )

Output:

tf.Tensor(
[[ 0.   +0.j    2.5  +2.5j   5.   +5.j    7.5  +7.5j  10.  +10.j  ]
 [ 5.   +5.j   13.75+13.75j 22.5 +22.5j  31.25+31.25j 40.  +40.j  ]], shape=(2, 5), dtype=complex64)
ang:
[[0.        0.7853982 0.7853982 0.7853982 0.7853982]
 [0.7853982 0.7853982 0.7853982 0.7853982 0.7853982]]
reverse_conjugate:
tf.Tensor(
[[0.-1.j 0.-1.j 0.-1.j 0.-1.j 0.-1.j]
 [0.-1.j 0.-1.j 0.-1.j 0.-1.j 0.-1.j]], shape=(2, 5), dtype=complex64)
angle_matrix:
tf.Tensor(
[[ 0.   +0.j    2.5  -2.5j   5.   -5.j    7.5  -7.5j  10.  -10.j  ]
 [ 5.   -5.j   13.75-13.75j 22.5 -22.5j  31.25-31.25j 40.  -40.j  ]], shape=(2, 5), dtype=complex64)
magnitude_matrix:
tf.Tensor(
[[ 0. +0.j  5. +0.j 10. +0.j 15. +0.j 20. +0.j]
 [10. +0.j 27.5+0.j 45. +0.j 62.5+0.j 80. +0.j]], shape=(2, 5), dtype=complex64)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.