Data Source (Core)#

alts.core.oracle.data_source
class DataSource(query_shape, result_shape)[source]#

Bases: Configurable, Queryable

Description
A DataSource is a source of learning data for the model in training.
It returns results (y-values) to given queries (x-values) upon request.
The generation of its data depends on the individual implementation.
Parameters:
  • query_shape (tuple of ints) – The expected shape of the queries

  • result_shape (tuple of ints) – The expected shape of the results

property exhausted: bool#
Description
A DataSource is exhausted if all its available data has been querried.
Returns False by default
Returns:

Whether the DataSource has been exhausted

Return type:

boolean

query(self, queries) data_points[source]#
Description
query() is the access point to the data of the DataSource.
It returns the results to given queries.
Parameters:

queries (NDArray) – Requested Query

Returns:

Processed Query [1] , Result

Return type:

A tuple of two NDArray

Raises:

NotImplementedError

query_constrain(self) QueryConstrain[source]#
Description
query_constrain() is a getter-function for the constrains around queries to the DataSource.
Constrains can affect the count, shape and the ranges of a query.
For more information, see Constrains
Current Constrains
Shape: query_shape
Value Range: (-inf, inf) for all values
Returns:

Constrains around queries

Return type:

QueryConstrain

query_shape: Tuple[int, ...] = NOTSET#
result_constrain(self) ResultConstrain[source]#
Description
result_constrain() is the equivalent of query_constrain() for results from the DataSource.
Current Constrains
Shape: result_shape
Returns:

Constrains to results

Return type:

ResultConstrain

result_shape: Tuple[int, ...] = NOTSET#
class TimeDataSource(query_shape)[source]#

Bases: DataSource

Description
A TimeDataSource is a DataSource in which the first entry of a query is a non-negative number (representing time).
Parameters:

result_shape (tuple of ints) – The expected shape of results

query(self, queries) data_points[source]#
Description
Parameters:

queries – Requested Query

Returns:

Processed Query, Result

Return type:

A tuple of two NDArray

Raises:

NotImplementedError

query_constrain(self) QueryConstrain[source]#
Current Constrains
Shape: query_shape, (1,)
Range of first value: [0, inf)
Range of other values: (-inf, inf)
Returns:

Constrains around queries

Return type:

QueryConstrain

query_shape: Tuple[int, ...] = (1,)#
class TimeDataSourceWraper(query_shape, data_source)[source]#

Bases: TimeDataSource

Description
A TimeDataSourceWrapper is a TimeDataSource that queries from another DataSource.
Parameters:
  • query_shape (tuple of ints) – The expected shape of queries

  • data_source (DataSource) – The DataSource to query from.

data_source: DataSource = NOTSET#
query(self, queries) data_points[source]#
Description
query() queries from the initialized DataSource data_source of the TimeDataSourceWrapper. See DataSource.query().
Parameters:

queries – Requested Query

Returns:

Processed Query, Result

Return type:

A tuple of two NDArray

query_constrain(self) QueryConstrain[source]#
Current Constrains
Shape: query_shape, (1,)
Range of first value: [0, t) where t is the upper bound of that value in data_source
Range of other values: (-inf, inf)
Returns:

Constrains around queries

Return type:

QueryConstrain

query_shape: Tuple[int, ...] = (1,)#