'Iterate through multiple inputs in tensorflow model

I am working on an image classification model in TensorFlow, that should use multiple video streams as input (frame-wise). As for some layers, those inputs are processed separately I used a for-loop to apply the layer for each video input... And this is probably not the way to do it. It looks something like that:

for i in tf.range(cameras_num_input):
    # frame input size (batch_size, 260, 260, 3, number_of_cameras)
    frame_input = all_frames_input[:, :, :, :, i]
    parameter_inverse = parameter_inverse_input[:, :, :, i]
    
    x= self.encoder(frame_input)
    x= self.CNNFusionLayer(x)
    x= self.MathFunction(x)
    
    all_tmp.append(x)

I looked at tf.vectorized_map(), tf.scan, tf.nest.map_structure, tf.while_loop, but they all seem not the right way to do it.

Some ideas to help out a beginner? ;)

All the best, der_manu



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source