idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
19,100
public void triggerEvent ( ) { try { lock . writeLock ( ) . lock ( ) ; long currentTime = System . currentTimeMillis ( ) ; if ( latestEvent . get ( ) == 0 ) this . latestEvent . set ( currentTime ) ; actualizeCounts ( currentTime ) ; int currentBin = ( int ) TimeUnit . SECONDS . convert ( currentTime , TimeUnit . MILLISECONDS ) % buckets . length ; buckets [ currentBin ] ++ ; if ( currentBin == buckets . length - 1 ) buckets [ 0 ] = 0 ; else buckets [ currentBin + 1 ] = 0 ; this . latestEvent . set ( currentTime ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } }
This method notifies timer about event
19,101
public long getNumberOfEvents ( ) { try { lock . readLock ( ) . lock ( ) ; long currentTime = System . currentTimeMillis ( ) ; actualizeCounts ( currentTime ) ; return sumCounts ( ) ; } finally { lock . readLock ( ) . unlock ( ) ; } }
This method returns total number of events happened withing predefined timeframe
19,102
public static INDArrayIndex [ ] indexesFor ( long ... shape ) { INDArrayIndex [ ] ret = new INDArrayIndex [ shape . length ] ; for ( int i = 0 ; i < shape . length ; i ++ ) { ret [ i ] = NDArrayIndex . point ( shape [ i ] ) ; } return ret ; }
Add indexes for the given shape
19,103
public static void updateForNewAxes ( INDArray arr , INDArrayIndex ... indexes ) { int numNewAxes = NDArrayIndex . numNewAxis ( indexes ) ; if ( numNewAxes >= 1 && ( indexes [ 0 ] . length ( ) > 1 || indexes [ 0 ] instanceof NDArrayIndexAll ) ) { List < Long > newShape = new ArrayList < > ( ) ; List < Long > newStrides = new ArrayList < > ( ) ; int currDimension = 0 ; for ( int i = 0 ; i < indexes . length ; i ++ ) { if ( indexes [ i ] instanceof NewAxis ) { newShape . add ( 1L ) ; newStrides . add ( 0L ) ; } else { newShape . add ( arr . size ( currDimension ) ) ; newStrides . add ( arr . size ( currDimension ) ) ; currDimension ++ ; } } while ( currDimension < arr . rank ( ) ) { newShape . add ( ( long ) currDimension ) ; newStrides . add ( ( long ) currDimension ) ; currDimension ++ ; } long [ ] newShapeArr = Longs . toArray ( newShape ) ; long [ ] newStrideArr = Longs . toArray ( newStrides ) ; arr . setShape ( newShapeArr ) ; arr . setStride ( newStrideArr ) ; } else { if ( numNewAxes > 0 ) { long [ ] newShape = Longs . concat ( ArrayUtil . toLongArray ( ArrayUtil . nTimes ( numNewAxes , 1 ) ) , arr . shape ( ) ) ; long [ ] newStrides = Longs . concat ( new long [ numNewAxes ] , arr . stride ( ) ) ; arr . setShape ( newShape ) ; arr . setStride ( newStrides ) ; } } }
Set the shape and stride for new axes based dimensions
19,104
public static INDArrayIndex [ ] nTimes ( INDArrayIndex copy , int n ) { INDArrayIndex [ ] ret = new INDArrayIndex [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { ret [ i ] = copy ; } return ret ; }
Repeat a copy of copy n times
19,105
public static int numPoints ( INDArrayIndex ... indexes ) { int ret = 0 ; for ( int i = 0 ; i < indexes . length ; i ++ ) if ( indexes [ i ] instanceof PointIndex ) ret ++ ; return ret ; }
Number of point indexes
19,106
public static int numNewAxis ( INDArrayIndex ... axes ) { int ret = 0 ; for ( INDArrayIndex index : axes ) if ( index instanceof NewAxis ) ret ++ ; return ret ; }
Given an array of indexes return the number of new axis elements in teh array
19,107
public static INDArrayIndex [ ] allFor ( INDArray arr ) { INDArrayIndex [ ] ret = new INDArrayIndex [ arr . rank ( ) ] ; for ( int i = 0 ; i < ret . length ; i ++ ) ret [ i ] = NDArrayIndex . all ( ) ; return ret ; }
Generate an all index equal to the rank of the given array
19,108
public void initializeInstance ( PopulationModel populationModel , ChromosomeFactory chromosomeFactory ) { super . initializeInstance ( populationModel , chromosomeFactory ) ; crossoverOperator . initializeInstance ( populationModel ) ; }
Called by GeneticSearchCandidateGenerator
19,109
public static Map < String , Set < Writable > > getUniqueSequence ( List < String > columnNames , Schema schema , SequenceRecordReader sequenceData ) { Map < String , Set < Writable > > m = new HashMap < > ( ) ; for ( String s : columnNames ) { m . put ( s , new HashSet < > ( ) ) ; } while ( sequenceData . hasNext ( ) ) { List < List < Writable > > next = sequenceData . sequenceRecord ( ) ; for ( List < Writable > step : next ) { for ( String s : columnNames ) { int idx = schema . getIndexOfColumn ( s ) ; m . get ( s ) . add ( step . get ( idx ) ) ; } } } return m ; }
Get a list of unique values from the specified columns of a sequence
19,110
public void setOrder ( char order ) { Preconditions . checkArgument ( order == 'c' || order == 'f' , "Order specified must be either c or f: got %s" , String . valueOf ( order ) ) ; this . order = order ; }
Sets the order . Primarily for testing purposes
19,111
public void setDType ( DataType dtype ) { assert dtype == DataType . DOUBLE || dtype == DataType . FLOAT || dtype == DataType . INT : "Invalid opType passed, must be float or double" ; }
Sets the data opType
19,112
public INDArray eye ( long n ) { INDArray ret = Nd4j . create ( n , n ) ; for ( int i = 0 ; i < n ; i ++ ) { ret . put ( i , i , 1.0 ) ; } return ret . reshape ( n , n ) ; }
Create the identity ndarray
19,113
public void rot90 ( INDArray toRotate ) { if ( ! toRotate . isMatrix ( ) ) throw new IllegalArgumentException ( "Only rotating matrices" ) ; INDArray start = toRotate . transpose ( ) ; for ( int i = 0 ; i < start . rows ( ) ; i ++ ) start . putRow ( i , reverse ( start . getRow ( i ) ) ) ; }
Rotate a matrix 90 degrees
19,114
public INDArray arange ( double begin , double end , double step ) { return Nd4j . create ( ArrayUtil . toDoubles ( ArrayUtil . range ( ( int ) begin , ( int ) end , ( int ) step ) ) ) ; }
Array of evenly spaced values .
19,115
public INDArray rand ( long rows , long columns ) { return rand ( new long [ ] { rows , columns } , System . currentTimeMillis ( ) ) ; }
Create a random ndarray with the given shape using the current time as the seed
19,116
public INDArray randn ( long rows , long columns ) { return randn ( new long [ ] { rows , columns } , System . currentTimeMillis ( ) ) ; }
Random normal using the current time stamp as the seed
19,117
public INDArray valueArrayOf ( int [ ] shape , double value ) { INDArray ret = Nd4j . createUninitialized ( shape , Nd4j . order ( ) ) ; ret . assign ( value ) ; return ret ; }
Creates an ndarray with the specified value as the only value in the ndarray
19,118
public INDArray valueArrayOf ( long rows , long columns , double value ) { INDArray create = createUninitialized ( new long [ ] { rows , columns } , Nd4j . order ( ) ) ; create . assign ( value ) ; return create ; }
Creates a row vector with the specified number of columns
19,119
public INDArray ones ( int [ ] shape ) { INDArray ret = createUninitialized ( shape , Nd4j . order ( ) ) ; ret . assign ( 1 ) ; return ret ; }
Create an ndarray of ones
19,120
public INDArray scalar ( Number value , long offset ) { if ( Nd4j . dataType ( ) == DataType . DOUBLE ) return scalar ( value . doubleValue ( ) , offset ) ; if ( Nd4j . dataType ( ) == DataType . FLOAT || Nd4j . dataType ( ) == DataType . HALF ) return scalar ( value . floatValue ( ) , offset ) ; if ( Nd4j . dataType ( ) == DataType . INT ) return scalar ( value . intValue ( ) , offset ) ; throw new IllegalStateException ( "Illegal data opType " + Nd4j . dataType ( ) ) ; }
Create a scalar ndarray with the specified offset
19,121
public static String unescape ( String text ) { StringBuilder builder = new StringBuilder ( ) ; boolean foundQuote = false ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) { char c = text . charAt ( i ) ; if ( i == 0 && c == QUOTE || i == text . length ( ) - 1 && c == QUOTE ) { continue ; } if ( c == QUOTE ) { if ( foundQuote ) { builder . append ( QUOTE ) ; foundQuote = false ; } else { foundQuote = true ; } } else { foundQuote = false ; builder . append ( c ) ; } } return builder . toString ( ) ; }
Unescape input for CSV
19,122
public static String escape ( String text ) { boolean hasQuote = text . indexOf ( QUOTE ) >= 0 ; boolean hasComma = text . indexOf ( COMMA ) >= 0 ; if ( ! ( hasQuote || hasComma ) ) { return text ; } StringBuilder builder = new StringBuilder ( ) ; if ( hasQuote ) { for ( int i = 0 ; i < text . length ( ) ; i ++ ) { char c = text . charAt ( i ) ; if ( c == QUOTE ) { builder . append ( QUOTE_ESCAPED ) ; } else { builder . append ( c ) ; } } } else { builder . append ( text ) ; } if ( hasComma ) { builder . insert ( 0 , QUOTE ) ; builder . append ( QUOTE ) ; } return builder . toString ( ) ; }
Escape input for CSV
19,123
public static long getOptimalBufferSize ( long paramsLength , int numWorkers , int queueSize ) { val bufferSize = ( ( paramsLength / 16 ) + 65536 ) * numWorkers * queueSize * 4 ; return bufferSize ; }
This method returns optimal bufferSize for a given model
19,124
public void touch ( ) { if ( index . get ( ) == null ) { int numDevces = Nd4j . getAffinityManager ( ) . getNumberOfDevices ( ) ; if ( numDevces > 1 && parties > 1 ) { int localIndex = Nd4j . getAffinityManager ( ) . getDeviceForCurrentThread ( ) ; index . set ( localIndex ) ; } else { index . set ( workersCounter . getAndIncrement ( ) ) ; } } }
This method does initialization of given worker wrt Thread - Device Affinity
19,125
public boolean subscriberLaunched ( ) { boolean launched = true ; for ( int i = 0 ; i < numWorkers ; i ++ ) { launched = launched && subscriber [ i ] . subscriberLaunched ( ) ; } return launched ; }
Returns true if all susbcribers in the subscriber pool have been launched
19,126
public void merge ( ROCMultiClass other ) { if ( this . underlying == null ) { this . underlying = other . underlying ; return ; } else if ( other . underlying == null ) { return ; } if ( underlying . length != other . underlying . length ) { throw new UnsupportedOperationException ( "Cannot merge ROCBinary: this expects " + underlying . length + "outputs, other expects " + other . underlying . length + " outputs" ) ; } for ( int i = 0 ; i < underlying . length ; i ++ ) { this . underlying [ i ] . merge ( other . underlying [ i ] ) ; } }
Merge this ROCMultiClass instance with another . This ROCMultiClass instance is modified by adding the stats from the other instance .
19,127
public INDArray inferSequence ( Sequence < T > sequence , long nr , double learningRate , double minLearningRate , int iterations ) { AtomicLong nextRandom = new AtomicLong ( nr ) ; if ( sequence . isEmpty ( ) ) return null ; Random random = Nd4j . getRandomFactory ( ) . getNewRandomInstance ( configuration . getSeed ( ) * sequence . hashCode ( ) , lookupTable . layerSize ( ) + 1 ) ; INDArray ret = Nd4j . rand ( new int [ ] { 1 , lookupTable . layerSize ( ) } , random ) . subi ( 0.5 ) . divi ( lookupTable . layerSize ( ) ) ; log . info ( "Inf before: {}" , ret ) ; for ( int iter = 0 ; iter < iterations ; iter ++ ) { for ( int i = 0 ; i < sequence . size ( ) ; i ++ ) { nextRandom . set ( Math . abs ( nextRandom . get ( ) * 25214903917L + 11 ) ) ; dm ( i , sequence , ( int ) nextRandom . get ( ) % window , nextRandom , learningRate , null , true , ret , null ) ; } learningRate = ( ( learningRate - minLearningRate ) / ( iterations - iter ) ) + minLearningRate ; } finish ( ) ; return ret ; }
This method does training on previously unseen paragraph and returns inferred vector
19,128
public void shutdown ( ) { if ( initLocker . get ( ) && shutdownLocker . compareAndSet ( false , true ) ) { log . info ( "Shutting down transport..." ) ; transport . shutdown ( ) ; executor . shutdown ( ) ; initFinished . set ( false ) ; initLocker . set ( false ) ; shutdownLocker . set ( false ) ; } }
This method initiates shutdown sequence for this instance .
19,129
public static Set < String > getLocalAddresses ( ) { try { List < NetworkInterface > interfaces = Collections . list ( NetworkInterface . getNetworkInterfaces ( ) ) ; Set < String > result = new HashSet < > ( ) ; for ( NetworkInterface networkInterface : interfaces ) { if ( networkInterface . isLoopback ( ) || ! networkInterface . isUp ( ) ) continue ; for ( InterfaceAddress address : networkInterface . getInterfaceAddresses ( ) ) { String addr = address . getAddress ( ) . getHostAddress ( ) ; if ( addr == null || addr . isEmpty ( ) || addr . contains ( ":" ) ) continue ; result . add ( addr ) ; } } return result ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
This method returns set of local IP addresses available in system .
19,130
public double [ ] [ ] selectParents ( ) { double [ ] [ ] parents = new double [ 2 ] [ ] ; int parent1Idx = rng . nextInt ( population . size ( ) ) ; int parent2Idx ; do { parent2Idx = rng . nextInt ( population . size ( ) ) ; } while ( parent1Idx == parent2Idx ) ; parents [ 0 ] = population . get ( parent1Idx ) . getGenes ( ) ; parents [ 1 ] = population . get ( parent2Idx ) . getGenes ( ) ; return parents ; }
Selects two random parents
19,131
public static List < Row > minMaxColumns ( DataRowsFacade data , List < String > columns ) { String [ ] arr = new String [ columns . size ( ) ] ; for ( int i = 0 ; i < arr . length ; i ++ ) arr [ i ] = columns . get ( i ) ; return minMaxColumns ( data , arr ) ; }
Returns the min and max of the given columns
19,132
public static List < Row > minMaxColumns ( DataRowsFacade data , String ... columns ) { return aggregate ( data , columns , new String [ ] { "min" , "max" } ) ; }
Returns the min and max of the given columns . The list returned is a list of size 2 where each row
19,133
public static List < Row > stdDevMeanColumns ( DataRowsFacade data , String ... columns ) { return aggregate ( data , columns , new String [ ] { "stddev" , "mean" } ) ; }
Returns the standard deviation and mean of the given columns The list returned is a list of size 2 where each row represents the standard deviation of each column and the mean of each column
19,134
public static List < Row > aggregate ( DataRowsFacade data , String [ ] columns , String [ ] functions ) { String [ ] rest = new String [ columns . length - 1 ] ; System . arraycopy ( columns , 1 , rest , 0 , rest . length ) ; List < Row > rows = new ArrayList < > ( ) ; for ( String op : functions ) { Map < String , String > expressions = new ListOrderedMap ( ) ; for ( String s : columns ) { expressions . put ( s , op ) ; } DataRowsFacade aggregated = dataRows ( data . get ( ) . agg ( expressions ) ) ; String [ ] columns2 = aggregated . get ( ) . columns ( ) ; Map < String , String > opReplace = new TreeMap < > ( ) ; for ( String s : columns2 ) { if ( s . contains ( "min(" ) || s . contains ( "max(" ) ) opReplace . put ( s , s . replace ( op , "" ) . replaceAll ( "[()]" , "" ) ) ; else if ( s . contains ( "avg" ) ) { opReplace . put ( s , s . replace ( "avg" , "" ) . replaceAll ( "[()]" , "" ) ) ; } else { opReplace . put ( s , s . replace ( op , "" ) . replaceAll ( "[()]" , "" ) ) ; } } DataRowsFacade rearranged = null ; for ( Map . Entry < String , String > entries : opReplace . entrySet ( ) ) { if ( rearranged == null ) { rearranged = dataRows ( aggregated . get ( ) . withColumnRenamed ( entries . getKey ( ) , entries . getValue ( ) ) ) ; } else rearranged = dataRows ( rearranged . get ( ) . withColumnRenamed ( entries . getKey ( ) , entries . getValue ( ) ) ) ; } rearranged = dataRows ( rearranged . get ( ) . select ( DataFrames . toColumns ( columns ) ) ) ; rows . addAll ( rearranged . get ( ) . collectAsList ( ) ) ; } return rows ; }
Aggregate based on an arbitrary list of aggregation and grouping functions
19,135
public static JavaRDD < List < Writable > > normalize ( Schema schema , JavaRDD < List < Writable > > data , List < String > skipColumns ) { return normalize ( schema , data , 0 , 1 , skipColumns ) ; }
Scale all data 0 to 1
19,136
public static int discretize ( double value , double min , double max , int binCount ) { int discreteValue = ( int ) ( binCount * normalize ( value , min , max ) ) ; return clamp ( discreteValue , 0 , binCount - 1 ) ; }
Discretize the given value
19,137
public static int binomial ( RandomGenerator rng , int n , double p ) { if ( ( p < 0 ) || ( p > 1 ) ) { return 0 ; } int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( rng . nextDouble ( ) < p ) { c ++ ; } } return c ; }
Generates a binomial distributed number using the given rng
19,138
public static double uniform ( Random rng , double min , double max ) { return rng . nextDouble ( ) * ( max - min ) + min ; }
Generate a uniform random number from the given rng
19,139
public static double ssReg ( double [ ] residuals , double [ ] targetAttribute ) { double mean = sum ( targetAttribute ) / targetAttribute . length ; double ret = 0 ; for ( int i = 0 ; i < residuals . length ; i ++ ) { ret += Math . pow ( residuals [ i ] - mean , 2 ) ; } return ret ; }
How much of the variance is explained by the regression
19,140
public static double ssError ( double [ ] predictedValues , double [ ] targetAttribute ) { double ret = 0 ; for ( int i = 0 ; i < predictedValues . length ; i ++ ) { ret += Math . pow ( targetAttribute [ i ] - predictedValues [ i ] , 2 ) ; } return ret ; }
How much of the variance is NOT explained by the regression
19,141
public static double stringSimilarity ( String ... strings ) { if ( strings == null ) return 0 ; Counter < String > counter = new Counter < > ( ) ; Counter < String > counter2 = new Counter < > ( ) ; for ( int i = 0 ; i < strings [ 0 ] . length ( ) ; i ++ ) counter . incrementCount ( String . valueOf ( strings [ 0 ] . charAt ( i ) ) , 1.0f ) ; for ( int i = 0 ; i < strings [ 1 ] . length ( ) ; i ++ ) counter2 . incrementCount ( String . valueOf ( strings [ 1 ] . charAt ( i ) ) , 1.0f ) ; Set < String > v1 = counter . keySet ( ) ; Set < String > v2 = counter2 . keySet ( ) ; Set < String > both = SetUtils . intersection ( v1 , v2 ) ; double sclar = 0 , norm1 = 0 , norm2 = 0 ; for ( String k : both ) sclar += counter . getCount ( k ) * counter2 . getCount ( k ) ; for ( String k : v1 ) norm1 += counter . getCount ( k ) * counter . getCount ( k ) ; for ( String k : v2 ) norm2 += counter2 . getCount ( k ) * counter2 . getCount ( k ) ; return sclar / Math . sqrt ( norm1 * norm2 ) ; }
Calculate string similarity with tfidf weights relative to each character frequency and how many times a character appears in a given string
19,142
public static double [ ] mergeCoords ( double [ ] x , double [ ] y ) { if ( x . length != y . length ) throw new IllegalArgumentException ( "Sample sizes must be the same for each data applyTransformToDestination." ) ; double [ ] ret = new double [ x . length + y . length ] ; for ( int i = 0 ; i < x . length ; i ++ ) { ret [ i ] = x [ i ] ; ret [ i + 1 ] = y [ i ] ; } return ret ; }
This will merge the coordinates of the given coordinate system .
19,143
public static double times ( double [ ] nums ) { if ( nums == null || nums . length == 0 ) return 0 ; double ret = 1 ; for ( int i = 0 ; i < nums . length ; i ++ ) ret *= nums [ i ] ; return ret ; }
This returns the product of all numbers in the given array .
19,144
public static double sumOfProducts ( double [ ] ... nums ) { if ( nums == null || nums . length < 1 ) return 0 ; double sum = 0 ; for ( int i = 0 ; i < nums . length ; i ++ ) { double [ ] column = column ( i , nums ) ; sum += times ( column ) ; } return sum ; }
This returns the sum of products for the given numbers .
19,145
private static double [ ] column ( int column , double [ ] ... nums ) throws IllegalArgumentException { double [ ] ret = new double [ nums . length ] ; for ( int i = 0 ; i < nums . length ; i ++ ) { double [ ] curr = nums [ i ] ; ret [ i ] = curr [ column ] ; } return ret ; }
This returns the given column over an n arrays
19,146
public static double [ ] xVals ( double [ ] vector ) { if ( vector == null ) return null ; double [ ] x = new double [ vector . length / 2 ] ; int count = 0 ; for ( int i = 0 ; i < vector . length ; i ++ ) { if ( i % 2 != 0 ) x [ count ++ ] = vector [ i ] ; } return x ; }
This returns the x values of the given vector . These are assumed to be the even values of the vector .
19,147
public static double [ ] yVals ( double [ ] vector ) { double [ ] y = new double [ vector . length / 2 ] ; int count = 0 ; for ( int i = 0 ; i < vector . length ; i ++ ) { if ( i % 2 == 0 ) y [ count ++ ] = vector [ i ] ; } return y ; }
This returns the odd indexed values for the given vector
19,148
public static double rootMeansSquaredError ( double [ ] real , double [ ] predicted ) { double ret = 0.0 ; for ( int i = 0 ; i < real . length ; i ++ ) { ret += Math . pow ( ( real [ i ] - predicted [ i ] ) , 2 ) ; } return Math . sqrt ( ret / real . length ) ; }
This returns the root mean squared error of two data sets
19,149
public void buildTree ( INDArray x ) { this . X = x ; for ( int i = 0 ; i < x . rows ( ) ; i ++ ) { root . getIndices ( ) . add ( i ) ; } RPUtils . buildTree ( this , root , rpHyperPlanes , x , maxSize , 0 , similarityFunction ) ; }
Build the tree with the given input data
19,150
public void initializeInstance ( PopulationModel populationModel ) { this . population = populationModel . getPopulation ( ) ; culledSize = ( int ) ( populationModel . getPopulationSize ( ) * ( 1.0 - cullRatio ) + 0.5 ) ; }
Will be called by the population model once created .
19,151
public void scoomv ( char transA , int M , DataBuffer values , DataBuffer rowInd , DataBuffer colInd , int nnz , INDArray x , INDArray y ) { mkl_cspblas_scoogemv ( Character . toString ( transA ) , ( IntPointer ) Nd4j . createBuffer ( new int [ ] { M } ) . addressPointer ( ) , ( FloatPointer ) values . addressPointer ( ) , ( IntPointer ) rowInd . addressPointer ( ) , ( IntPointer ) colInd . addressPointer ( ) , ( IntPointer ) Nd4j . createBuffer ( new int [ ] { nnz } ) . addressPointer ( ) , ( FloatPointer ) x . data ( ) . addressPointer ( ) , ( FloatPointer ) y . data ( ) . addressPointer ( ) ) ; }
Mapping with Sparse Blas calls
19,152
public void setConf ( Configuration conf ) { super . setConf ( conf ) ; numFeatures = conf . getInt ( NUM_FEATURES , - 1 ) ; if ( numFeatures < 0 ) numFeatures = conf . getInt ( NUM_ATTRIBUTES , - 1 ) ; if ( numFeatures < 0 ) throw new UnsupportedOperationException ( "numFeatures must be set in configuration" ) ; appendLabel = conf . getBoolean ( APPEND_LABEL , true ) ; multilabel = conf . getBoolean ( MULTILABEL , false ) ; zeroBasedIndexing = conf . getBoolean ( ZERO_BASED_INDEXING , true ) ; zeroBasedLabelIndexing = conf . getBoolean ( ZERO_BASED_LABEL_INDEXING , false ) ; numLabels = conf . getInt ( NUM_LABELS , - 1 ) ; if ( multilabel && numLabels < 0 ) throw new UnsupportedOperationException ( "numLabels must be set in confirmation for multilabel problems" ) ; }
Set configuration .
19,153
protected Writable getNextRecord ( ) { Writable w = null ; if ( recordLookahead != null ) { w = recordLookahead ; recordLookahead = null ; } while ( w == null && super . hasNext ( ) ) { w = super . next ( ) . iterator ( ) . next ( ) ; if ( ! w . toString ( ) . startsWith ( COMMENT_CHAR ) ) break ; w = null ; } return w ; }
Helper function to help detect lines that are commented out . May read ahead and cache a line .
19,154
public Record nextRecord ( ) { List < Writable > next = next ( ) ; URI uri = ( locations == null || locations . length < 1 ? null : locations [ splitIndex ] ) ; RecordMetaData meta = new RecordMetaDataLine ( this . lineIndex - 1 , uri , SVMLightRecordReader . class ) ; return new org . datavec . api . records . impl . Record ( next , meta ) ; }
Return next Record .
19,155
public Random getRandom ( ) { try { if ( threadRandom . get ( ) == null ) { Random t = ( Random ) randomClass . newInstance ( ) ; if ( t . getStatePointer ( ) != null ) { } threadRandom . set ( t ) ; return t ; } return threadRandom . get ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
This method returns Random implementation instance associated with calling thread
19,156
public Random getNewRandomInstance ( long seed ) { try { Random t = ( Random ) randomClass . newInstance ( ) ; if ( t . getStatePointer ( ) != null ) { } t . setSeed ( seed ) ; return t ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
This method returns new onject implementing Random interface initialized with seed value
19,157
public Random getNewRandomInstance ( long seed , long size ) { try { Class < ? > c = randomClass ; Constructor < ? > constructor = c . getConstructor ( long . class , long . class ) ; Random t = ( Random ) constructor . newInstance ( seed , size ) ; return t ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
This method returns new onject implementing Random interface initialized with seed value with size of elements in buffer
19,158
public INDArray loadSingleSentence ( String sentence ) { List < String > tokens = tokenizeSentence ( sentence ) ; if ( format == Format . CNN1D || format == Format . RNN ) { int [ ] featuresShape = new int [ ] { 1 , wordVectorSize , Math . min ( maxSentenceLength , tokens . size ( ) ) } ; INDArray features = Nd4j . create ( featuresShape , ( format == Format . CNN1D ? 'c' : 'f' ) ) ; INDArrayIndex [ ] indices = new INDArrayIndex [ 3 ] ; indices [ 0 ] = NDArrayIndex . point ( 0 ) ; for ( int i = 0 ; i < featuresShape [ 2 ] ; i ++ ) { INDArray vector = getVector ( tokens . get ( i ) ) ; indices [ 1 ] = NDArrayIndex . all ( ) ; indices [ 2 ] = NDArrayIndex . point ( i ) ; features . put ( indices , vector ) ; } return features ; } else { int [ ] featuresShape = new int [ ] { 1 , 1 , 0 , 0 } ; if ( sentencesAlongHeight ) { featuresShape [ 2 ] = Math . min ( maxSentenceLength , tokens . size ( ) ) ; featuresShape [ 3 ] = wordVectorSize ; } else { featuresShape [ 2 ] = wordVectorSize ; featuresShape [ 3 ] = Math . min ( maxSentenceLength , tokens . size ( ) ) ; } INDArray features = Nd4j . create ( featuresShape ) ; int length = ( sentencesAlongHeight ? featuresShape [ 2 ] : featuresShape [ 3 ] ) ; INDArrayIndex [ ] indices = new INDArrayIndex [ 4 ] ; indices [ 0 ] = NDArrayIndex . point ( 0 ) ; indices [ 1 ] = NDArrayIndex . point ( 0 ) ; for ( int i = 0 ; i < length ; i ++ ) { INDArray vector = getVector ( tokens . get ( i ) ) ; if ( sentencesAlongHeight ) { indices [ 2 ] = NDArrayIndex . point ( i ) ; indices [ 3 ] = NDArrayIndex . all ( ) ; } else { indices [ 2 ] = NDArrayIndex . all ( ) ; indices [ 3 ] = NDArrayIndex . point ( i ) ; } features . put ( indices , vector ) ; } return features ; } }
Generally used post training time to load a single sentence for predictions
19,159
public static NormalizerSerializer getDefault ( ) { if ( defaultSerializer == null ) { defaultSerializer = new NormalizerSerializer ( ) . addStrategy ( new StandardizeSerializerStrategy ( ) ) . addStrategy ( new MinMaxSerializerStrategy ( ) ) . addStrategy ( new MultiStandardizeSerializerStrategy ( ) ) . addStrategy ( new MultiMinMaxSerializerStrategy ( ) ) . addStrategy ( new ImagePreProcessingSerializerStrategy ( ) ) . addStrategy ( new MultiHybridSerializerStrategy ( ) ) ; } return defaultSerializer ; }
Get the default serializer configured with strategies for the built - in normalizer implementations
19,160
private NormalizerSerializerStrategy getStrategy ( Normalizer normalizer ) { for ( NormalizerSerializerStrategy strategy : strategies ) { if ( strategySupportsNormalizer ( strategy , normalizer . getType ( ) , normalizer . getClass ( ) ) ) { return strategy ; } } throw new RuntimeException ( String . format ( "No serializer strategy found for normalizer of class %s. If this is a custom normalizer, you probably " + "forgot to register a corresponding custom serializer strategy with this serializer." , normalizer . getClass ( ) ) ) ; }
Get a serializer strategy the given normalizer
19,161
private NormalizerSerializerStrategy getStrategy ( Header header ) throws Exception { if ( header . normalizerType . equals ( NormalizerType . CUSTOM ) ) { return header . customStrategyClass . newInstance ( ) ; } for ( NormalizerSerializerStrategy strategy : strategies ) { if ( strategySupportsNormalizer ( strategy , header . normalizerType , null ) ) { return strategy ; } } throw new RuntimeException ( "No serializer strategy found for given header " + header ) ; }
Get a serializer strategy the given serialized file header
19,162
private boolean strategySupportsNormalizer ( NormalizerSerializerStrategy strategy , NormalizerType normalizerType , Class < ? extends Normalizer > normalizerClass ) { if ( ! strategy . getSupportedType ( ) . equals ( normalizerType ) ) { return false ; } if ( strategy . getSupportedType ( ) . equals ( NormalizerType . CUSTOM ) ) { if ( ! ( strategy instanceof CustomSerializerStrategy ) ) { throw new IllegalArgumentException ( "Strategies supporting CUSTOM opType must be instance of CustomSerializerStrategy, got" + strategy . getClass ( ) ) ; } return ( ( CustomSerializerStrategy ) strategy ) . getSupportedClass ( ) . equals ( normalizerClass ) ; } return true ; }
Check if a serializer strategy supports a normalizer . If the normalizer is a custom opType it checks if the supported normalizer class matches .
19,163
private Header parseHeader ( InputStream stream ) throws IOException , ClassNotFoundException { DataInputStream dis = new DataInputStream ( stream ) ; String header = dis . readUTF ( ) ; if ( ! header . equals ( HEADER ) ) { throw new IllegalArgumentException ( "Could not restore normalizer: invalid header. If this normalizer was saved with a opType-specific " + "strategy like StandardizeSerializerStrategy, use that class to restore it as well." ) ; } int version = dis . readInt ( ) ; if ( version != 1 ) { throw new IllegalArgumentException ( "Could not restore normalizer: invalid version (" + version + ")" ) ; } NormalizerType type = NormalizerType . valueOf ( dis . readUTF ( ) ) ; if ( type . equals ( NormalizerType . CUSTOM ) ) { String strategyClassName = dis . readUTF ( ) ; return new Header ( type , ( Class < ? extends NormalizerSerializerStrategy > ) Class . forName ( strategyClassName ) ) ; } else { return new Header ( type , null ) ; } }
Parse the data header
19,164
private void writeHeader ( OutputStream stream , Header header ) throws IOException { DataOutputStream dos = new DataOutputStream ( stream ) ; dos . writeUTF ( HEADER ) ; dos . writeInt ( 1 ) ; dos . writeUTF ( header . normalizerType . toString ( ) ) ; if ( header . customStrategyClass != null ) { dos . writeUTF ( header . customStrategyClass . getName ( ) ) ; } }
Write the data header
19,165
public void autoAttachStatsStorageBySessionId ( Function < String , StatsStorage > statsStorageProvider ) { if ( statsStorageProvider != null ) { this . statsStorageLoader = new StatsStorageLoader ( statsStorageProvider ) ; } }
Auto - attach StatsStorage if an unknown session ID is passed as URL path parameter in multi - session mode
19,166
public INDArray createFromNpyPointer ( Pointer pointer ) { Pointer dataPointer = nativeOps . dataPointForNumpy ( pointer ) ; int dataBufferElementSize = nativeOps . elementSizeForNpyArray ( pointer ) ; DataBuffer data = null ; Pointer shapeBufferPointer = nativeOps . shapeBufferForNumpy ( pointer ) ; int length = nativeOps . lengthForShapeBufferPointer ( shapeBufferPointer ) ; shapeBufferPointer . capacity ( 8 * length ) ; shapeBufferPointer . limit ( 8 * length ) ; shapeBufferPointer . position ( 0 ) ; val intPointer = new LongPointer ( shapeBufferPointer ) ; val newPointer = new LongPointer ( length ) ; val perfD = PerformanceTracker . getInstance ( ) . helperStartTransaction ( ) ; Pointer . memcpy ( newPointer , intPointer , shapeBufferPointer . limit ( ) ) ; PerformanceTracker . getInstance ( ) . helperRegisterTransaction ( 0 , perfD , shapeBufferPointer . limit ( ) , MemcpyDirection . HOST_TO_HOST ) ; DataBuffer shapeBuffer = Nd4j . createBuffer ( newPointer , DataType . LONG , length , LongIndexer . create ( newPointer ) ) ; dataPointer . position ( 0 ) ; dataPointer . limit ( dataBufferElementSize * Shape . length ( shapeBuffer ) ) ; dataPointer . capacity ( dataBufferElementSize * Shape . length ( shapeBuffer ) ) ; if ( dataBufferElementSize == ( Float . SIZE / 8 ) ) { FloatPointer dPointer = new FloatPointer ( dataPointer . limit ( ) / dataBufferElementSize ) ; val perfX = PerformanceTracker . getInstance ( ) . helperStartTransaction ( ) ; Pointer . memcpy ( dPointer , dataPointer , dataPointer . limit ( ) ) ; PerformanceTracker . getInstance ( ) . helperRegisterTransaction ( 0 , perfX , dataPointer . limit ( ) , MemcpyDirection . HOST_TO_HOST ) ; data = Nd4j . createBuffer ( dPointer , DataType . FLOAT , Shape . length ( shapeBuffer ) , FloatIndexer . create ( dPointer ) ) ; } else if ( dataBufferElementSize == ( Double . SIZE / 8 ) ) { DoublePointer dPointer = new DoublePointer ( dataPointer . limit ( ) / dataBufferElementSize ) ; val perfX = PerformanceTracker . getInstance ( ) . helperStartTransaction ( ) ; Pointer . memcpy ( dPointer , dataPointer , dataPointer . limit ( ) ) ; PerformanceTracker . getInstance ( ) . helperRegisterTransaction ( 0 , perfX , dataPointer . limit ( ) , MemcpyDirection . HOST_TO_HOST ) ; data = Nd4j . createBuffer ( dPointer , DataType . DOUBLE , Shape . length ( shapeBuffer ) , DoubleIndexer . create ( dPointer ) ) ; } INDArray ret = Nd4j . create ( data , Shape . shape ( shapeBuffer ) , Shape . strideArr ( shapeBuffer ) , 0 , Shape . order ( shapeBuffer ) ) ; Nd4j . getAffinityManager ( ) . tagLocation ( ret , AffinityManager . Location . DEVICE ) ; return ret ; }
Create from an in memory numpy pointer . Note that this is heavily used in our python library jumpy .
19,167
public boolean toBoolean ( String name , boolean defaultValue ) { String property = getProperties ( ) . getProperty ( name ) ; return property != null ? Boolean . parseBoolean ( property ) : defaultValue ; }
Get property . The method returns the default value if the property is not parsed .
19,168
public static SubscriberState empty ( ) { val map = new ConcurrentHashMap < String , Number > ( ) ; return SubscriberState . builder ( ) . serverState ( "empty" ) . streamId ( - 1 ) . parameterUpdaterStatus ( map ) . totalUpdates ( - 1 ) . isMaster ( false ) . build ( ) ; }
Returns an empty subscriber state with - 1 as total updates master as false and server state as empty
19,169
public INDArray getById ( int id ) { return map . get ( NodeDescriptor . builder ( ) . id ( id ) . build ( ) ) ; }
This method returns array identified its numeric id
19,170
public INDArray [ ] asArray ( ) { val val = map . values ( ) ; val res = new INDArray [ val . size ( ) ] ; int cnt = 0 ; for ( val v : val ) res [ cnt ++ ] = v ; return res ; }
This method return operands as array in order of addition
19,171
public Collection < Pair < NodeDescriptor , INDArray > > asCollection ( ) { val c = new HashSet < Pair < NodeDescriptor , INDArray > > ( ) ; for ( val k : map . keySet ( ) ) c . add ( Pair . makePair ( k , map . get ( k ) ) ) ; return c ; }
This method returns contents of this entity as collection of key - > value pairs
19,172
public static int lengthForDtype ( DataType type ) { switch ( type ) { case DOUBLE : return 8 ; case FLOAT : return 4 ; case INT : return 4 ; case HALF : return 2 ; case LONG : return 8 ; case COMPRESSED : default : throw new IllegalArgumentException ( "Illegal opType for length" ) ; } }
Returns the length for the given data opType
19,173
public static DataType getDtypeFromContext ( String dType ) { switch ( dType ) { case "double" : return DataType . DOUBLE ; case "float" : return DataType . FLOAT ; case "int" : return DataType . INT ; case "half" : return DataType . HALF ; default : return DataType . FLOAT ; } }
Get the allocation mode from the context
19,174
public static DataType getDtypeFromContext ( ) { try { lock . readLock ( ) . lock ( ) ; if ( dtype == null ) { lock . readLock ( ) . unlock ( ) ; lock . writeLock ( ) . lock ( ) ; if ( dtype == null ) dtype = getDtypeFromContext ( Nd4jContext . getInstance ( ) . getConf ( ) . getProperty ( "dtype" ) ) ; lock . writeLock ( ) . unlock ( ) ; lock . readLock ( ) . lock ( ) ; } return dtype ; } finally { lock . readLock ( ) . unlock ( ) ; } }
get the allocation mode from the context
19,175
public static void validateNonNegative ( int [ ] data , String paramName ) { if ( data == null ) { return ; } boolean nonnegative = true ; for ( int value : data ) { if ( value < 0 ) { nonnegative = false ; } } Preconditions . checkArgument ( nonnegative , "Values for %s must be >= 0, got: %s" , paramName , data ) ; }
Checks that all values are > = 0 .
19,176
public static int [ ] validate1NonNegative ( int [ ] data , String paramName ) { validateNonNegative ( data , paramName ) ; return validate1 ( data , paramName ) ; }
Reformats the input array to a length 1 array and checks that all values are > = 0 .
19,177
public static int [ ] validate1 ( int [ ] data , String paramName ) { if ( data == null ) { return null ; } Preconditions . checkArgument ( data . length == 1 , "Need 1 %s value, got %s values: %s" , paramName , data . length , data ) ; return data ; }
Reformats the input array to a length 1 array .
19,178
public static int [ ] validate2NonNegative ( int [ ] data , boolean allowSz1 , String paramName ) { validateNonNegative ( data , paramName ) ; return validate2 ( data , allowSz1 , paramName ) ; }
Reformats the input array to a length 2 array and checks that all values are > = 0 .
19,179
public static int [ ] validate2 ( int [ ] data , boolean allowSz1 , String paramName ) { if ( data == null ) { return null ; } if ( allowSz1 ) { Preconditions . checkArgument ( data . length == 1 || data . length == 2 , "Need either 1 or 2 %s values, got %s values: %s" , paramName , data . length , data ) ; } else { Preconditions . checkArgument ( data . length == 2 , "Need 2 %s values, got %s values: %s" , paramName , data . length , data ) ; } if ( data . length == 1 ) { return new int [ ] { data [ 0 ] , data [ 0 ] } ; } else { return data ; } }
Reformats the input array to a length 2 array .
19,180
public static int [ ] [ ] validate2x2NonNegative ( int [ ] [ ] data , String paramName ) { for ( int [ ] part : data ) validateNonNegative ( part , paramName ) ; return validate2x2 ( data , paramName ) ; }
Reformats the input array to a 2x2 array and checks that all values are > = 0 .
19,181
public static int [ ] validate3NonNegative ( int [ ] data , String paramName ) { validateNonNegative ( data , paramName ) ; return validate3 ( data , paramName ) ; }
Reformats the input array to a length 3 array and checks that all values > = 0 .
19,182
public static int [ ] validate3 ( int [ ] data , String paramName ) { if ( data == null ) { return null ; } Preconditions . checkArgument ( data . length == 1 || data . length == 3 , "Need either 1 or 3 %s values, got %s values: %s" , paramName , data . length , data ) ; if ( data . length == 1 ) { return new int [ ] { data [ 0 ] , data [ 0 ] , data [ 0 ] } ; } else { return data ; } }
Reformats the input array to a length 3 array .
19,183
public static int [ ] validate4NonNegative ( int [ ] data , String paramName ) { validateNonNegative ( data , paramName ) ; return validate4 ( data , paramName ) ; }
Reformats the input array to a length 4 array and checks that all values > = 0 .
19,184
public static int [ ] validate4 ( int [ ] data , String paramName ) { if ( data == null ) { return null ; } Preconditions . checkArgument ( data . length == 1 || data . length == 2 || data . length == 4 , "Need either 1, 2, or 4 %s values, got %s values: %s" , paramName , data . length , data ) ; if ( data . length == 1 ) { return new int [ ] { data [ 0 ] , data [ 0 ] , data [ 0 ] , data [ 0 ] } ; } else if ( data . length == 2 ) { return new int [ ] { data [ 0 ] , data [ 0 ] , data [ 1 ] , data [ 1 ] } ; } else { return data ; } }
Reformats the input array to a length 4 array .
19,185
public static int [ ] validate6NonNegative ( int [ ] data , String paramName ) { validateNonNegative ( data , paramName ) ; return validate6 ( data , paramName ) ; }
Reformats the input array to a length 6 array and checks that all values > = 0 .
19,186
public static int [ ] validate6 ( int [ ] data , String paramName ) { if ( data == null ) { return null ; } Preconditions . checkArgument ( data . length == 1 || data . length == 3 || data . length == 6 , "Need either 1, 3, or 6 %s values, got %s values: %s" , paramName , data . length , data ) ; if ( data . length == 1 ) { return new int [ ] { data [ 0 ] , data [ 0 ] , data [ 0 ] , data [ 0 ] , data [ 0 ] , data [ 0 ] } ; } else if ( data . length == 3 ) { return new int [ ] { data [ 0 ] , data [ 0 ] , data [ 1 ] , data [ 1 ] , data [ 2 ] , data [ 2 ] } ; } else { return data ; } }
Reformats the input array to a length 6 array .
19,187
public Collection < String > wordsNearest ( String label , int n ) { if ( ! vocabCache . hasToken ( label ) ) return new ArrayList < > ( ) ; Collection < String > collection = wordsNearest ( Arrays . asList ( label ) , new ArrayList < String > ( ) , n + 1 ) ; if ( collection . contains ( label ) ) collection . remove ( label ) ; return collection ; }
This method returns nearest words for target word based on tree structure . This method is recommended to use if you re going to call for nearest words multiple times . VPTree will be built upon firt call to this method
19,188
public static TimingStatistics averageFileRead ( long nTimes , RecordReader recordReader , File file , INDArrayCreationFunction function ) throws Exception { TimingStatistics timingStatistics = null ; for ( int i = 0 ; i < nTimes ; i ++ ) { TimingStatistics timingStatistics1 = timeNDArrayCreation ( recordReader , new BufferedInputStream ( new FileInputStream ( file ) ) , function ) ; if ( timingStatistics == null ) timingStatistics = timingStatistics1 ; else { timingStatistics = timingStatistics . add ( timingStatistics1 ) ; } } return timingStatistics . average ( nTimes ) ; }
Returns statistics for components of a datavec pipeline averaged over the specified number of times
19,189
public static INDArrayIndex [ ] adjustIndices ( int [ ] originalShape , INDArrayIndex ... indexes ) { if ( Shape . isVector ( originalShape ) && indexes . length == 1 ) return indexes ; if ( indexes . length < originalShape . length ) indexes = fillIn ( originalShape , indexes ) ; if ( indexes . length > originalShape . length ) { INDArrayIndex [ ] ret = new INDArrayIndex [ originalShape . length ] ; System . arraycopy ( indexes , 0 , ret , 0 , originalShape . length ) ; return ret ; } if ( indexes . length == originalShape . length ) return indexes ; for ( int i = 0 ; i < indexes . length ; i ++ ) { if ( indexes [ i ] . end ( ) >= originalShape [ i ] || indexes [ i ] instanceof NDArrayIndexAll ) indexes [ i ] = NDArrayIndex . interval ( 0 , originalShape [ i ] - 1 ) ; } return indexes ; }
Prunes indices of greater length than the shape and fills in missing indices if there are any
19,190
public static boolean isContiguous ( int [ ] indices , int diff ) { if ( indices . length < 1 ) return true ; for ( int i = 1 ; i < indices . length ; i ++ ) { if ( Math . abs ( indices [ i ] - indices [ i - 1 ] ) > diff ) return false ; } return true ; }
Returns whether indices are contiguous by a certain amount or not
19,191
public static INDArrayIndex [ ] createFromStartAndEnd ( INDArray start , INDArray end ) { if ( start . length ( ) != end . length ( ) ) throw new IllegalArgumentException ( "Start length must be equal to end length" ) ; else { if ( start . length ( ) > Integer . MAX_VALUE ) throw new ND4JIllegalStateException ( "Can't proceed with INDArray with length > Integer.MAX_VALUE" ) ; INDArrayIndex [ ] indexes = new INDArrayIndex [ ( int ) start . length ( ) ] ; for ( int i = 0 ; i < indexes . length ; i ++ ) { indexes [ i ] = NDArrayIndex . interval ( start . getInt ( i ) , end . getInt ( i ) ) ; } return indexes ; } }
Create an n dimensional index based on the given interval indices . Start and end represent the begin and end of each interval
19,192
public static int [ ] stride ( INDArray arr , INDArrayIndex [ ] indexes , int ... shape ) { List < Integer > strides = new ArrayList < > ( ) ; int strideIndex = 0 ; List < Integer > prependNewAxes = new ArrayList < > ( ) ; for ( int i = 0 ; i < indexes . length ; i ++ ) { if ( indexes [ i ] instanceof PointIndex ) { strideIndex ++ ; continue ; } else if ( indexes [ i ] instanceof NewAxis ) { } } for ( int i = 0 ; i < prependNewAxes . size ( ) ; i ++ ) { strides . add ( prependNewAxes . get ( i ) - i , 1 ) ; } return Ints . toArray ( strides ) ; }
Return the stride to be used for indexing
19,193
public static boolean isScalar ( INDArray indexOver , INDArrayIndex ... indexes ) { boolean allOneLength = true ; for ( int i = 0 ; i < indexes . length ; i ++ ) { allOneLength = allOneLength && indexes [ i ] . length ( ) == 1 ; } int numNewAxes = NDArrayIndex . numNewAxis ( indexes ) ; if ( allOneLength && numNewAxes == 0 && indexes . length == indexOver . rank ( ) ) return true ; else if ( allOneLength && indexes . length == indexOver . rank ( ) - numNewAxes ) { return allOneLength ; } return allOneLength ; }
Check if the given indexes over the specified array are searching for a scalar
19,194
public void sgetrf ( int M , int N , INDArray A , INDArray IPIV , INDArray INFO ) { int status = LAPACKE_sgetrf ( getColumnOrder ( A ) , M , N , ( FloatPointer ) A . data ( ) . addressPointer ( ) , getLda ( A ) , ( IntPointer ) IPIV . data ( ) . addressPointer ( ) ) ; if ( status < 0 ) { throw new BlasException ( "Failed to execute sgetrf" , status ) ; } }
L U DECOMP
19,195
public void getri ( int N , INDArray A , int lda , int [ ] IPIV , INDArray WORK , int lwork , int INFO ) { }
Generate inverse given LU decomp
19,196
protected void jointMessageHandler ( DirectBuffer buffer , int offset , int length , Header header ) { byte [ ] data = new byte [ length ] ; buffer . getBytes ( offset , data ) ; val message = VoidMessage . fromBytes ( data ) ; if ( ! remoteConnections . containsKey ( message . getOriginatorId ( ) ) ) addConnection ( message . getOriginatorId ( ) ) ; log . debug ( "Got [{}] message from [{}]" , message . getClass ( ) . getSimpleName ( ) , message . getOriginatorId ( ) ) ; try { messageQueue . put ( message ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } }
This method converts aeron buffer into VoidMessage and puts into temp queue for further processing
19,197
public double f1Score ( INDArray examples , INDArray labels ) { Evaluation eval = new Evaluation ( ) ; eval . eval ( labels , activate ( examples , false , LayerWorkspaceMgr . noWorkspacesImmutable ( ) ) ) ; return eval . f1 ( ) ; }
Returns the f1 score for the given examples . Think of this to be like a percentage right . The higher the number the more it got right . This is on a scale from 0 to 1 .
19,198
public int [ ] predict ( INDArray input ) { INDArray output = activate ( input , false , LayerWorkspaceMgr . noWorkspacesImmutable ( ) ) ; int [ ] ret = new int [ input . rows ( ) ] ; for ( int i = 0 ; i < ret . length ; i ++ ) ret [ i ] = Nd4j . getBlasWrapper ( ) . iamax ( output . getRow ( i ) ) ; return ret ; }
Returns the predictions for each example in the dataset
19,199
public List < String > predict ( DataSet dataSet ) { int [ ] intRet = predict ( dataSet . getFeatures ( ) ) ; List < String > ret = new ArrayList < > ( ) ; for ( int i : intRet ) { ret . add ( i , dataSet . getLabelName ( i ) ) ; } return ret ; }
Return predicted label names