corners

Corners objective function, defined for box-like environments, such as the hyper-grid and the cube.

The function places high scores in all corners of the hyper-box according to either of these options:

  • A mixture of Gaussians. Optionally, the scores and can be thresholded in order to make the task harder.

  • A hard-coded function that assigns each point of the hyper-box to one of three scores (this matches the function used in the original GFlowNets paper):

    • High scores: points in the corners at a distance from the edge between 0.2 and 0.1 the length of the box.

    • Middle scores: points in the corners at distance from the edge within a quarter the length of the box.

    • Low scores: all other points.

Classes

Corners

Initializes an instance of the Corners proxy.

Module Contents

class corners.Corners(n_dim=None, mu=None, sigma=None, do_gaussians=True, do_threshold=False, thresholds=((0.0, 2.0, 1e-06), (2.0, 3.0, 2.0), (3.0, 100, 10.0)), scores=[2.0, 0.5, 0.01], **kwargs)[source]

Bases: gflownet.proxy.base.Proxy

Initializes an instance of the Corners proxy.

Parameters:
  • n_dim (int) – Dimensionality of the hyper-box.

  • mu (float) – Mean of the Gaussian distributions that make the objective function. It should be a value between 0.0 and 1.0. A value closer to 1.0 places the regions of high scores closer to the edges (in the corners) and a value closer to 0.0 places the regions of high scores closer to the center.

  • sigma (float) – Standard deviation of the Gaussian distributions that make the objective function.

  • do_gaussians (bool) – If True, the score landscape is modelled by a mixture of Gaussians. Otherwise, the scores are assigned via an indicator function, as in the original GFlowNets paper.

  • do_threshold (bool) – If True, the values of the Gaussians are thresholded using the values in thresholds.

  • thresholds (iterable) – A list of tuples with the information to threshold the objective function. The first two values of the tuple indicate the lower and upper bound of a range, and the third value indicates the value onto which values in the range are mapped. For example, (0.0, 1.0, 1e-6) will map all values between 0.0 and 1.0 to 1e-6.

  • scores (iterable) – The scores of the three regions for the non-Gaussian version. It should be a list with three elements, where the first element is highest score, the second element the middle score and the third element the lowest score.

n_dim = None[source]
mu = None[source]
sigma = None[source]
do_gaussians = True[source]
do_threshold = False[source]
thresholds[source]
scores = (2.0, 0.5, 0.01)[source]
setup(env=None)[source]
property optimum[source]

Returns the optimum value of the proxy.

Not implemented by default but may be implemented for synthetic proxies or when the optimum is known.

The optimum is used, for example, to accelerate rejection sampling, to sample from the reward function.

__call__(states)[source]

Implement this function to call the get_reward method of the appropriate Proxy Class (EI, UCB, Proxy, Oracle etc).

Parameters:

states (ndarray)

Return type:

torchtyping.TensorType[batch]