Package org.deeplearning4j.util
Class TimeSeriesUtils
- java.lang.Object
-
- org.deeplearning4j.util.TimeSeriesUtils
-
public class TimeSeriesUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RNNFormatgetFormatFromRnnLayer(Layer layer)Get theRNNFormatfrom the RNN layer, accounting for the presence of wrapper layers like Bidirectional, LastTimeStep, etcstatic INDArraymovingAverage(INDArray toAvg, int n)Calculate a moving average given the lengthstatic Pair<INDArray,int[]>pullLastTimeSteps(INDArray pullFrom, INDArray mask)Extract out the last time steps (2d array from 3d array input) accounting for the mask layer, if present.static Pair<INDArray,int[]>pullLastTimeSteps(INDArray pullFrom, INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)Extract out the last time steps (2d array from 3d array input) accounting for the mask layer, if present.static INDArrayreshape2dTo3d(INDArray in, int miniBatchSize)static INDArrayreshape2dTo3d(INDArray in, long miniBatchSize, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)static INDArrayreshape3dTo2d(INDArray in)static INDArrayreshape3dTo2d(INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)static INDArrayreshapeCnnMaskToTimeSeriesMask(INDArray timeSeriesMaskAsCnnMask, int minibatchSize)Reshape CNN-style 4d mask array of shape [seqLength*minibatch,1,1,1] to time series mask [mb,seqLength] This should match the assumptions (f order, etc) in RnnOutputLayerstatic INDArrayreshapePerOutputTimeSeriesMaskTo2d(INDArray perOutputTimeSeriesMask)static INDArrayreshapePerOutputTimeSeriesMaskTo2d(INDArray perOutputTimeSeriesMask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)static INDArrayreshapeTimeSeriesMaskToCnn4dMask(INDArray timeSeriesMask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)Reshape time series mask arrays.static INDArrayreshapeTimeSeriesMaskToVector(INDArray timeSeriesMask)Reshape time series mask arrays.static INDArrayreshapeTimeSeriesMaskToVector(INDArray timeSeriesMask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)Reshape time series mask arrays.static INDArrayreshapeVectorToTimeSeriesMask(INDArray timeSeriesMaskAsVector, int minibatchSize)Reshape time series mask arrays.static INDArrayreverseTimeSeries(INDArray in)Reverse an input time series along the time dimensionstatic INDArrayreverseTimeSeries(INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)Reverse an input time series along the time dimensionstatic INDArrayreverseTimeSeries(INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType, RNNFormat dataFormat)static INDArrayreverseTimeSeriesMask(INDArray mask)Reverse a (per time step) time series mask, with shape [minibatch, timeSeriesLength]static INDArrayreverseTimeSeriesMask(INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)Reverse a (per time step) time series mask, with shape [minibatch, timeSeriesLength]
-
-
-
Method Detail
-
movingAverage
public static INDArray movingAverage(INDArray toAvg, int n)
Calculate a moving average given the length- Parameters:
toAvg- the array to averagen- the length of the moving window- Returns:
- the moving averages for each row
-
reshapeTimeSeriesMaskToVector
public static INDArray reshapeTimeSeriesMaskToVector(INDArray timeSeriesMask)
Reshape time series mask arrays. This should match the assumptions (f order, etc) in RnnOutputLayer- Parameters:
timeSeriesMask- Mask array to reshape to a column vector- Returns:
- Mask array as a column vector
-
reshapeTimeSeriesMaskToVector
public static INDArray reshapeTimeSeriesMaskToVector(INDArray timeSeriesMask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
Reshape time series mask arrays. This should match the assumptions (f order, etc) in RnnOutputLayer- Parameters:
timeSeriesMask- Mask array to reshape to a column vector- Returns:
- Mask array as a column vector
-
reshapeTimeSeriesMaskToCnn4dMask
public static INDArray reshapeTimeSeriesMaskToCnn4dMask(INDArray timeSeriesMask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
Reshape time series mask arrays. This should match the assumptions (f order, etc) in RnnOutputLayer This reshapes from [X,1] to [X,1,1,1] suitable for per-example masking in CNNs- Parameters:
timeSeriesMask- Mask array to reshape for CNN per-example masking- Returns:
- Mask array as 4D CNN mask array: [X, 1, 1, 1]
-
reshapeVectorToTimeSeriesMask
public static INDArray reshapeVectorToTimeSeriesMask(INDArray timeSeriesMaskAsVector, int minibatchSize)
Reshape time series mask arrays. This should match the assumptions (f order, etc) in RnnOutputLayer- Parameters:
timeSeriesMaskAsVector- Mask array to reshape to a column vector- Returns:
- Mask array as a column vector
-
reshapeCnnMaskToTimeSeriesMask
public static INDArray reshapeCnnMaskToTimeSeriesMask(INDArray timeSeriesMaskAsCnnMask, int minibatchSize)
Reshape CNN-style 4d mask array of shape [seqLength*minibatch,1,1,1] to time series mask [mb,seqLength] This should match the assumptions (f order, etc) in RnnOutputLayer- Parameters:
timeSeriesMaskAsCnnMask- Mask array to reshape- Returns:
- Sequence mask array - [minibatch, sequenceLength]
-
reshapePerOutputTimeSeriesMaskTo2d
public static INDArray reshapePerOutputTimeSeriesMaskTo2d(INDArray perOutputTimeSeriesMask)
-
reshapePerOutputTimeSeriesMaskTo2d
public static INDArray reshapePerOutputTimeSeriesMaskTo2d(INDArray perOutputTimeSeriesMask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
-
reshape3dTo2d
public static INDArray reshape3dTo2d(INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
-
reshape2dTo3d
public static INDArray reshape2dTo3d(INDArray in, long miniBatchSize, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
-
reverseTimeSeries
public static INDArray reverseTimeSeries(INDArray in)
Reverse an input time series along the time dimension- Parameters:
in- Input activations to reverse, with shape [minibatch, size, timeSeriesLength]- Returns:
- Reversed activations
-
reverseTimeSeries
public static INDArray reverseTimeSeries(INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType, RNNFormat dataFormat)
-
reverseTimeSeries
public static INDArray reverseTimeSeries(INDArray in, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
Reverse an input time series along the time dimension- Parameters:
in- Input activations to reverse, with shape [minibatch, size, timeSeriesLength]- Returns:
- Reversed activations
-
reverseTimeSeriesMask
public static INDArray reverseTimeSeriesMask(INDArray mask)
Reverse a (per time step) time series mask, with shape [minibatch, timeSeriesLength]- Parameters:
mask- Mask to reverse along time dimension- Returns:
- Mask after reversing
-
reverseTimeSeriesMask
public static INDArray reverseTimeSeriesMask(INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
Reverse a (per time step) time series mask, with shape [minibatch, timeSeriesLength]- Parameters:
mask- Mask to reverse along time dimension- Returns:
- Mask after reversing
-
pullLastTimeSteps
public static Pair<INDArray,int[]> pullLastTimeSteps(INDArray pullFrom, INDArray mask)
Extract out the last time steps (2d array from 3d array input) accounting for the mask layer, if present.- Parameters:
pullFrom- Input time series array (rank 3) to pull the last time steps frommask- Mask array (rank 2). May be null- Returns:
- 2d array of the last time steps
-
pullLastTimeSteps
public static Pair<INDArray,int[]> pullLastTimeSteps(INDArray pullFrom, INDArray mask, LayerWorkspaceMgr workspaceMgr, ArrayType arrayType)
Extract out the last time steps (2d array from 3d array input) accounting for the mask layer, if present.- Parameters:
pullFrom- Input time series array (rank 3) to pull the last time steps frommask- Mask array (rank 2). May be null- Returns:
- 2d array of the last time steps
-
-