box_embeddings.parameterizations.sigmoid_box_tensor

Implementation of sigmoid box parameterization.

Module Contents

class SigmoidBoxTensor(data: Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]])

Bases: box_embeddings.parameterizations.box_tensor.BoxTensor

Sigmoid Box Tensor

property z(self) → torch.Tensor

Lower left coordinate as Tensor

Returns

lower left corner

Return type

Tensor

property Z(self) → torch.Tensor

Top right coordinate as Tensor

Returns

top right corner

Return type

Tensor

classmethod W(cls: Type[box_embeddings.parameterizations.box_tensor.TBoxTensor], z: torch.Tensor, Z: torch.Tensor, *args: Any, **kwargs: Any) → torch.Tensor

Given (z,Z), it returns one set of valid box weights W, such that Box(W) = (z,Z).

Parameters
  • z – Lower left coordinate of shape (…, hidden_dims)

  • Z – Top right coordinate of shape (…, hidden_dims)

  • *args – extra arguments for child class

  • **kwargs – extra arguments for child class

Returns

Parameters of the box. In base class implementation, this

will have shape (…, 2, hidden_dims).

Return type

Tensor

classmethod from_vector(cls: Type[box_embeddings.parameterizations.box_tensor.TBoxTensor], vector: torch.Tensor, *args: Any, **kwargs: Any) → box_embeddings.parameterizations.box_tensor.BoxTensor

Creates a box for a vector. In this base implementation the vector is split into two pieces and these are used as box weights.

Parameters
  • vector – tensor

  • *args – extra arguments for child class

  • **kwargs – extra arguments for child class

Returns

A BoxTensor

Raises

ValueError – if last dimension is not even