Skip to content

Instantly share code, notes, and snippets.

@talolard
Created January 14, 2019 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talolard/2fc7334f8dc491b582e918b1a0bfd600 to your computer and use it in GitHub Desktop.
Save talolard/2fc7334f8dc491b582e918b1a0bfd600 to your computer and use it in GitHub Desktop.
Sampling a portfolio from a dirichlet distribution
self.alphas= tf.contrib.layers.fully_connected(
inputs=l2,
num_outputs=num_stocks+1,
activation_fn=tf.nn.relu,
weights_initializer=tf.initializers.glorot_uniform)
self.alphas +=1
self.dirichlet = tfp.distributions.Dirichlet(self.alphas)
self.action = self.dirichlet._sample_n(1)
self.action = tf.squeeze(self.action)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment