Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tfd_cross_entropy

Computes the (Shannon) cross entropy.


Description

Denote this distribution (self) by P and the other distribution by Q. Assuming P, Q are absolutely continuous with respect to one another and permit densities p(x) dr(x) and q(x) dr(x), (Shannon) cross entropy is defined as: H[P, Q] = E_p[-log q(X)] = -int_F p(x) log q(x) dr(x) where F denotes the support of the random variable X ~ P.

Usage

tfd_cross_entropy(distribution, other, name = "cross_entropy")

Arguments

distribution

The distribution being used.

other

tfp$distributions$Distribution instance.

name

String prepended to names of ops created by this function.

Value

cross_entropy: self.dtype Tensor with shape [B1, ..., Bn] representing n different calculations of (Shannon) cross entropy.

See Also

Examples

d1 <- tfd_normal(loc = 1, scale = 1)
  d2 <- tfd_normal(loc = 2, scale = 1)
  d1 %>% tfd_cross_entropy(d2)

tfprobability

Interface to 'TensorFlow Probability'

v0.11.0.0
Apache License (>= 2.0)
Authors
Sigrid Keydana [aut, cre], Daniel Falbel [ctb], Kevin Kuo [ctb] (<https://orcid.org/0000-0001-7803-7901>), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.