Trains an autoencoder adapted to the data and extracts its encoding for the same data matrix.

autoencode(data, dim, type = "basic", activation = "linear", epochs = 20)

Arguments

data

Numeric matrix to be encoded

dim

Number of variables to be used in the encoding

type

Type of autoencoder to use: "basic", "sparse", "contractive", "denoising", "robust" or "variational"

activation

Activation type to be used in the encoding layer. Some available activations are "tanh", "sigmoid", "relu", "elu" and "selu"

epochs

Number of times the data will traverse the autoencoder to update its weights

Value

Matrix containing the encodings

See also

\link{autoencoder}

Examples

inputs <- as.matrix(iris[, 1:4])

# \donttest{
if (keras::is_keras_available()) {
  # Train a basic autoencoder and generate a 2-variable encoding
  encoded <- autoencode(inputs, 2)

  # Train a contractive autoencoder with tanh activation
  encoded <- autoencode(inputs, 2, type = "contractive", activation = "tanh")
}
# }