public class SameDiffUtils extends Object
Constructor and Description |
---|
SameDiffUtils() |
Modifier and Type | Method and Description |
---|---|
static ExternalErrorsFunction |
externalErrors(SameDiff sameDiff,
Map<String,INDArray> externalGradients,
SDVariable... inputs) |
static ExternalErrorsFunction |
externalErrors(SameDiff sameDiff,
SDVariable[] inputs) |
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
|
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.
|
static SDVariable |
reductionBroadcastableWithOrigShape(SDVariable origInput,
SDVariable axis,
SDVariable toExpand) |
static SDVariable |
reductionShape(SDVariable shape,
SDVariable axis,
boolean keepDim) |
static Map<String,INDArray> |
stackOutputs(List<Map<String,INDArray>> outputs)
Stack batch outputs, like an output from
SameDiff.output(MultiDataSetIterator, String...) |
static void |
validateDifferentialFunctionSameDiff(SameDiff sameDiff,
SDVariable function,
DifferentialFunction op) |
public static Map<String,INDArray> stackOutputs(List<Map<String,INDArray>> outputs)
SameDiff.output(MultiDataSetIterator, String...)
public static List<INDArray> getSingleOutput(List<Map<String,INDArray>> outputs, String output)
public static ExternalErrorsFunction externalErrors(SameDiff sameDiff, Map<String,INDArray> externalGradients, SDVariable... inputs)
public static ExternalErrorsFunction externalErrors(SameDiff sameDiff, SDVariable[] inputs)
public static SDVariable reductionBroadcastableWithOrigShape(int origRank, int[] reduceDims, SDVariable toExpand)
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.
origRank
- Rank of the original array, before the reduction was executedreduceDims
- Dimensions that the original array was reduced fromtoExpand
- Array to add 1s to the shape to (such that it can bepublic static SDVariable reductionBroadcastableWithOrigShape(SDVariable origInput, SDVariable axis, SDVariable toExpand)
public static SDVariable reductionShape(SDVariable shape, SDVariable axis, boolean keepDim)
public static void validateDifferentialFunctionSameDiff(SameDiff sameDiff, SDVariable function, DifferentialFunction op)
Copyright © 2020. All rights reserved.