The ML.RECONSTRUCTION_LOSS function

This document describes the ML.RECONSTRUCTION_LOSS function, which you can use to compute the reconstruction losses between the input and output data of an autoencoder model.

Syntax

ML.RECONSTRUCTION_LOSS(
  MODEL `project_id.dataset.model`,
  { TABLE `project_id.dataset.table_name` | (query_statement) }
)

Arguments

ML.RECONSTRUCTION_LOSS takes the following arguments:

  • project_id: Your project ID.
  • dataset: The BigQuery dataset that contains the model.
  • model: The name of the model.
  • table: The name of the input data table.

    If you specify table_name, the input column names in the table must match the column names in the model, and their types must be compatible according to BigQuery implicit coercion rules.

  • query_statement: The GoogleSQL query to use for input data to generate the reconstruction losses. For the supported SQL syntax of the query_statement clause in GoogleSQL, see Query syntax.

    If you specify query_statement, the input column names from the query must match the column names in the model, and their types must be compatible according to BigQuery implicit coercion rules.

    If you used the TRANSFORM clause in the CREATE MODEL statement that created the model, then you can only use the input columns present in the TRANSFORM clause in the query_statement.

Output

ML.RECONSTRUCTION_LOSS returns the following columns:

  • mean_absolute_error: a FLOAT64 value that contains the mean absolute error for the model.
  • mean_squared_error: a FLOAT64 value that contains the mean squared error for the model.
  • mean_squared_log_error: a FLOAT64 value that contains the mean squared log error for the model.

Limitations

ML.RECONSTRUCTION_LOSS doesn't support imported TensorFlow models.

Example

The following query computes reconstruction losses for the model mydataset.mymodel in your default project:

SELECT *
FROM ML.RECONSTRUCTION_LOSS(
  MODEL `mydataset.mymodel`,
  (SELECT column1,
          column2,
          column3,
          column4
   FROM `mydataset.mytable`)
)

What's next