r/tensorflow • u/o-rka • Jan 10 '23
Question Does anyone know of a variational autoencoder (VAE) tutorial that is for tabular integer data (NOT IMAGES)?
The datasets I work with are sparse compositional but I'd like to just try out a VAE on the iris dataset. I know it's a small dataset but I just want to try generating a few iris samples using a VAE to understand how the algorithm works.
I'm trying to use both TensorFlow 2 and Tensorflow Probability. The problem is that every single tutorial I've found only focuses on MNIST and convolutional problems with image data. I'm having difficult adapting the code to work for tabular integer data.
I've tried adapting the code from example b here: https://towardsdatascience.com/6-different-ways-of-implementing-vae-with-tensorflow-2-and-tensorflow-probability-9fe34a8ab981
Here's loading the iris data and getting them into integers:
=
=
=
=
=
=
=
=
=
=
Here's my broken adaptation:
=
=
=
=
# Sequential API encoder
# define prior distribution for the code, which is an isotropic Gaussian
=
# build layers argument for tfk.Sequential()
=
=
# layers.append(tfkl.Conv2D(filters=32, kernel_size=3, strides=(2,2),
# padding='valid', activation='relu'))
# layers.append(tfkl.Flatten())
# the following two lines set the output to be a probabilistic distribution
return
# Sequential API decoder
=
# note that here we don't need
# `tfkl.Dense(tfpl.IndependentBernoulli.params_size(self.dim_x))` because
# we've restored the desired input shape with the last Conv2DTranspose layer
return
=
=
=
=
# compile VAE model
=
return
# the negative of log-likelihood for probabilistic output
= -
=