Comments (2)
This would be hugely useful if anyone's interested in contributing!
For the record, the following model works:
def build_neural_network():
inputs = tf.keras.layers.Input(...)
net = tf.keras.layers.Dense(X, 15, activation='relu')(inputs)
net = tf.keras.layers.Dense(15, activation=tf.nn.relu)(net)
locs = tf.keras.layers.Dense(K, activation=None)(net)
scales = tf.keras.layers.Dense(K, activation=tf.exp)(net)
logits = tf.keras.layers.Dense(K, activation=None)(net)
model = tf.keras.Model(inputs=inputs, outputs=[locs, scales, logits])
return model
K = 20 # number of mixture components
features = ... # data features
neural_network = build_neural_network()
locs, scales, logits = neural_network(features)
cat = Categorical(logits=logits)
components = [Normal(loc=loc, scale=scale) for loc, scale
in zip(tf.unstack(tf.transpose(locs)),
tf.unstack(tf.transpose(scales)))]
y = Mixture(cat=cat, components=components, value=tf.zeros_like(features))
You can then train it using gradient descent following any TF 2.0 tutorial.
from edward2.
Thanks, Dustin! Can you please verify that the references to Categorical and Normal are from edward2, and not tfp.distributions?
When running the above using Categorical and Normal from edward2, I get the following error:
TypeError: cat must be a Categorical distribution, but saw: RandomVariable("Categorical_1/", shape=(?,), dtype = int32)
Also, do you mind sharing a pointer to one such TF 2.0 tutorial? I am running TF 1.14.0 and TFP 0.7.0.
from edward2.
Related Issues (20)
- Gaussian Process confronts "Cholesky decomposition was not successful. The input might not be valid." HOT 2
- Problem when using `NCPNormalOutput`with mini-batches
- `gp_kernel_scale_trainable=True` in RandomFeatureGaussianProcess does not work
- Stochastic Block Model in edward2
- Scaled loss in Mimo HOT 2
- [QUESTION] Weighting KL Divergence HOT 1
- Variational inference with implicit probabilistic models HOT 4
- `bug` No convergence using bayesian LSTMCell HOT 5
- AttributeError: module 'edward2' has no attribute 'layers' HOT 2
- Where should I put my dataset in?
- Path error
- there is a bug about 'get_ dropout_ mask_ for_cell' in recurrent.py
- JAX SpectralNormalization shape error with vanilla nn.Dense layer HOT 4
- Unable to use heteroscedastic layers in tf.keras
- hetsngp.py missing in edward2 version 0.0.2
- HeteroscedasticSNGPLayer error with num_classes=2
- Just tried pip install edward2 I still cant use klqp (for KL diverenge) with it also edward is not compatible with TF2
- Installation problem WSL HOT 2
- Edward2 backend HOT 3
- AttributeError: module 'edward2.tensorflow' has no attribute 'interception'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edward2.