this post was submitted on 28 Nov 2023
1 points (100.0% liked)

Machine Learning

1 readers
1 users here now

Community Rules:

founded 1 year ago
MODERATORS
 

Let's say I have a model, which has 2 inputs. The first input is a number, and the second input is another number, which in reality is a class.

This model is split into 2 submodels. First sub-model works on the input, and the second sub-model works on the output of the first sub-model.

The value of the first input will very greatly by the output of the second. Thus, I wish to be able to have multiple candidates of the first sub-model, and dynamically select which one to use at each step, both during training and inference, based on the value (class) of the second input.

I did not manage to achieve this. I tried using the tf.cond, the tf.switch_case and several other things, but I never managed. When I asked chat GPT it said I should be using PyTorch for this. Is there really no way to do this ?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] puppet_pals@alien.top 1 points 11 months ago (1 children)

Looks good. You probably want something like:

tf.cond(categ==0, dense0(inputs), dense1(inputs))

[โ€“] work_account_mp@alien.top 1 points 11 months ago

I've got 8 categories and a lot of data, so the problem with this is that it becomes really slow, because it expects the inputs to have been passed through already.