Class SameDiffUtils


  • public class SameDiffUtils
    extends Object
    • Constructor Detail

      • SameDiffUtils

        public SameDiffUtils()
    • Method Detail

      • getSingleOutput

        public static List<INDArray> getSingleOutput​(List<Map<String,​INDArray>> outputs,
                                                     String output)
        Get a list of batch outputs for a single variable from a list of batch outputs for all variables
      • reductionBroadcastableWithOrigShape

        public static SDVariable reductionBroadcastableWithOrigShape​(int origRank,
                                                                     int[] reduceDims,
                                                                     SDVariable toExpand)
        Add 1s as required to the array make an array possible to be broadcast with the original (pre-reduce) array.

        Example: if doing [a,b,c].sum(1), result is [a,c]. To 'undo' this in a way that can be auto-broadcast, we want to expand as required - i.e., [a,c] -> [a,1,c] which can be auto-broadcast with the original [a,b,c]. This is typically only used with reduction operations backprop.

        Parameters:
        origRank - Rank of the original array, before the reduction was executed
        reduceDims - Dimensions that the original array was reduced from
        toExpand - Array to add 1s to the shape to (such that it can be
        Returns:
        Reshaped array.