1

So I've seen this post and this post but I'm still confused.

If I have data of the shape (3, 4, 4, 2) then that means I have two data points (spectrograms in my actual use case) and each point has two channels (two different signals).

I want to normalize my data as quickly as possible, so I'm trying to avoid the for loop and use tensorflow.linalg.normalize but i cannot seem to get the axis parameter under control.

As I understand it, the axis argument applies the normalization along the given axis:

from the docs: If axis is a Python integer, the input is considered a batch of vectors, and axis determines the axis in tensor over which to compute vector norms.

I want to normalize every data point and within that I want the normalization to be separate for each channel.

If it were a loop, I would do this

for i in range(3):
    for j in range(2):
         data[i, :, :, j] = tensorflow.linalg.normalize(data[i, :, :, j])

I would assume that the way to do this with the axis argument is to use axis=(0, -1) (normalize over the first axis then also for every channel) but the results I get don't match my expected results. Am I doing something wrong? Or am I misunderstanding something more fundamental?

Travasaurus
  • 601
  • 1
  • 8
  • 26

0 Answers0