Class TensorPair<V>

  • Type Parameters:
    V - the type of the values of the tensors

    public final class TensorPair<V>
    extends AbstractPair<Tensor<V>>
    A pair of tensors which are used together in several occasions.
    • Method Detail

      • fromLeftRight

        public static <V> TensorPair<V> fromLeftRight​(Tensor<V> leftTensor,
                                                      Tensor<V> rightTensor)
      • get

        public ValuePair<V> get​(PositionPair positionPair)
        Retrieves a pair of values from the two tensors. The left position in the given pair is used to access the left tensor and the right position to access the right tensor. The given position pair must not be null and non-null values have to be present in the tensors. In all other cases, exceptions will be thrown.
        Parameters:
        positionPair - the pair of positions for which the values have to be retrieved
        Returns:
        a pair of values, if they exist in the tensors
        Throws:
        java.lang.NullPointerException - if the given position pair is null or one of the values, retrieved from the tensors is null
      • getAll

        public java.util.List<ValuePair<V>> getAll​(java.lang.Iterable<PositionPair> positionPairs)
        Extracts all the value pairs of the tensor pair, according to the given iterable of position pairs. The returned list will contain all the value pairs in the order of the position pairs.
        Parameters:
        positionPairs - the position pairs for which the value pairs have to be extracte
        Returns:
        a list, containing all the pairs retrieved from the two tensors
        Throws:
        java.lang.NullPointerException - if the given positionPairs are null, or no values are contained for at least one of the positions.
      • mapValues

        public <K> com.google.common.collect.ListMultimap<K,​ValuePair<V>> mapValues​(com.google.common.collect.Multimap<K,​PositionPair> positionPairs)
        Extracts pairs of values, according to the given multimap of position pairs and returns them again as a multimap. The map will contain the same keys as the input map and as values all the values indexed by the given position pairs (values of the input map). It is assumed that values exist in the tensors for all given positions. If this is not the case, then an exception will be thrown. The returned value will be a ListMultimap, because it is easily possible that the returned value pairs are the same for different keys.
        Parameters:
        positionPairs - a multimap K: pairs of positions for which to retrieve the values
        Returns:
        a multimap K: pairs of values, extracted from the tensor pair