tensorflow / tensorflow/probability
How to save and load trained trainable_variables in tensorflow probability distribution?
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
I want to build a flow model which I can save the trained model.
flow = tfd.TransformedDistribution(
...
distribution=tfd.Normal(loc=0.0, scale=1.0),
bijector=my_bijectors
)
for e in epochs:
...
with tf.GradientTape() as tape:
log_prob_loss = loss() # some loss func here
grads = tape.gradient(log_prob_loss, flow.trainable_variables)
optimizer.apply_gradients(zip(grads, flow.trainable_variables))
...
How can I save and load the flow here?
I was thinking about using pickle to save the trainable_variables, but I don't know how to apply the loaded trained trainable_variables to the orignal one. Is there a way to update it?
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 by reviewing the flow construction and the trainable_variables update shown in the issue, including the proposed pickle approach. Determine the supported save and load path for the trained flow and how restored values are applied; done means the guidance explains both operations clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- tensorflow
- Domain
- machine-learning
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100