question_quasar
question_quasar

Reputation: 103

PyTorch: Handling multiple functions and arguments

I have a large number of neural networks (such that I have to use list comprehension to produce them), say [f_1, f_2, f_3 ...], collectively denoted by F.

I have the argument X = [x_1, x_2, x_3 ...], such that input tensor x_i is intended for the network f_i. The tensors I have will be big, owing to the data and then the gradients.

Is there an elegant (and efficient) way of obtaining the sequence [f_1(x_1), f_2(x_2), f_3(x_3) ...]?

Upvotes: 0

Views: 142

Answers (1)

flawr
flawr

Reputation: 11628

You could again use a list comprehension:

out = [f(x) for f,x in zip(F,X)]

Upvotes: 2

Related Questions