pmlayer.torch.layers.HLattice ================================== Hierarchical lattice layer with partially monotone constraints for PyTorch. .. code-block:: python class HLattice( num_input_dims, lattice_sizes, indices_increasing, neural_network=None) Parameters --------------------------------- =================== =============== =================================================================================== Args Type Description =================== =============== =================================================================================== num_input_dims int The length of input feature vectors. lattice_sizes Tensor (long) The latice sizes of monotonically increasing features. Each entry corresponds to a monotonically increasing feature, and each entry must be at least 2. indices_increasing list of int The list of indices of monotonically increasing features. neural_network neural network Default: ``None``. By setting this parameter, the sub-network internally used in this layer can be replaced. =================== =============== =================================================================================== Tensor Shape --------------------------------- ==================== ============================================================== I/O Shape ==================== ============================================================== Input (N, num_input_dims) Output (N, 1) ==================== ============================================================== N usually corresponds the batch size. .. note:: Each value in the input tensor must be between 0 and 1. Example --------------------------------- The following code transforms input tensor x into output tensor y, and the output (the shape of y) is ``(128,1)``. .. code-block:: python sizes = torch.tensor([4,4], dtype=torch.long) l = HLattice(10, sizes, [2,3]) x = torch.randn(128, 10) y = l(x) print(y.shape)