'Randomly select one node as the output in the neural network using tensorflow
I have three well-trained DNNs, and I would like to randomly select one at a time as the output of the combined model. It is something like dropout, but not exactly. How can I guarantee there is one and only one model selected?
Solution 1:[1]
You did not provide much information about your models and code, so I will just assume:
- create a field of three given models that are already loaded in memory:
I am not 100% sure if this is the correct way to make list of objects here, you will maybe need to append the objects to an empty list (not tested myself).model1 = ... model2 = ... model3 = ... models = [model1, model2, model3] - randomly select one of the models:
index = random.randint(0, 2) randomModel = models[index] - now you can use it
randomModel.predict(givenData)
This is just rough idea, provide more details if needed further help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ruli |
