tensorflow / tensorflow/probability
Cannot sample from DistributionLayer
Open
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
# Model
n_mvn = 5
output_dim = 2
input_layer = k.layers.Input(shape=(x.shape[1],))
learner = k.layers.Dense(tfp.layers.MixtureNormal.params_size(n_mvn, [output_dim]))(input_layer)
learner = tfp.layers.MixtureNormal(n_mvn, [output_dim], name='generator')(learner)
model = k.models.Model(input_layer, learner)
print(model.summary())
model.compile(
loss=lambda y, stuff: -stuff.log_prob(y),
optimizer=k.optimizers.Adam(0.01)
)
hist = model.fit(
x, x,
batch_size=1024, epochs=500,
validation_split=0.1,
callbacks=[k.callbacks.EarlyStopping(patience=50)],
verbose=True,
)
Please notice I have a MixtureNormal layer in the keras model. I have search literally everywhere. Am I really supposed to believe that there is absolutely no way to get this layer to produce random numbers or call .sample() in some way?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MixtureNormal layer and DistributionLayer sampling API, then reproduce the provided Keras model to establish the current behavior. Determine whether a supported sampling path exists or what API change is needed, and add or update coverage so the requested random-number generation is demonstrably usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100