box_embeddings.parameterizations.tf_delta_box_tensor
¶
Implementation of min-delta box parameterization.
Module Contents¶
- class TFMinDeltaBoxTensor(data: Union[tensorflow.Tensor, Tuple[tensorflow.Tensor, tensorflow.Tensor]], beta: float = 1.0, threshold: float = 20)¶
Bases:
box_embeddings.parameterizations.tf_box_tensor.TFBoxTensor
Unconstrained min-delta box tensor.
For input of the shape (…, 2, box_dim), this parameterization defines z=w, and Z=w + delta, where w and delta come from the -2th dimension of the input. It uses softplus to keep the delta positive.
- property kwargs(self) Dict ¶
Configuration attribute values
- Returns
Dict
- property args(self) Tuple ¶
- property Z(self) tensorflow.Tensor ¶
Top right coordinate as Tensor
- Returns
top right corner
- Return type
Tensor
- classmethod W(cls: Type[box_embeddings.parameterizations.tf_box_tensor.TFTBoxTensor], z: tensorflow.Tensor, Z: tensorflow.Tensor, beta: float = 1.0, threshold: float = 20.0) tensorflow.Tensor ¶
Given (z,Z), it returns one set of valid box weights W, such that Box(W) = (z,Z).
The min coordinate is stored as is: W[…,0,:] = z W[…,1,:] = softplus_inverse(Z-z)
The max coordinate is transformed
- Parameters
z – Lower left coordinate of shape (…, hidden_dims)
Z – Top right coordinate of shape (…, hidden_dims)
beta – TODO
threshold – TODO
- Returns
- Parameters of the box. In base class implementation, this
will have shape (…, 2, hidden_dims).
- Return type
Tensor
- classmethod from_vector(cls, vector: tensorflow.Tensor, beta: float = 1.0, threshold: float = 20) box_embeddings.parameterizations.tf_box_tensor.TFBoxTensor ¶
Creates a box for a vector. In this base implementation the vector is split into two pieces and these are used as z and delta.
- Parameters
vector – tensor
beta – beta parameter for softplus for delta. Depending on the universe box and your inputs ranges, you might want to change this. Higher values of beta will make softplus harder and bring it close to ReLU.
threshold – parameter for the softplus for delta
- Returns
A BoxTensor
- Raises
ValueError – if last dimension is not even