idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
19,900
public int iamin ( INDArray arr ) { if ( arr . isSparse ( ) ) { return Nd4j . getSparseBlasWrapper ( ) . level1 ( ) . iamin ( arr ) ; } else { throw new UnsupportedOperationException ( ) ; } }
finds the element of a vector that has the minimum absolute value .
19,901
public void swap ( INDArray x , INDArray y ) { if ( Nd4j . getExecutioner ( ) . getProfilingMode ( ) == OpExecutioner . ProfilingMode . ALL ) OpProfiler . getInstance ( ) . processBlasCall ( false , x , y ) ; if ( x . isSparse ( ) || y . isSparse ( ) ) { Nd4j . getSparseBlasWrapper ( ) . level1 ( ) . swap ( x , y ) ; r...
swaps a vector with another vector .
19,902
public void copy ( long n , DataBuffer x , int offsetX , int incrX , DataBuffer y , int offsetY , int incrY ) { if ( supportsDataBufferL1Ops ( ) ) { if ( x . dataType ( ) == DataType . DOUBLE ) { dcopy ( n , x , offsetX , incrX , y , offsetY , incrY ) ; } else { scopy ( n , x , offsetX , incrX , y , offsetY , incrY ) ;...
copy a vector to another vector .
19,903
public void rotg ( INDArray a , INDArray b , INDArray c , INDArray s ) { throw new UnsupportedOperationException ( ) ; }
computes parameters for a Givens rotation .
19,904
public void rot ( long N , INDArray X , INDArray Y , double c , double s ) { if ( Nd4j . getExecutioner ( ) . getProfilingMode ( ) == OpExecutioner . ProfilingMode . ALL ) OpProfiler . getInstance ( ) . processBlasCall ( false , X , Y ) ; if ( X . isSparse ( ) && ! Y . isSparse ( ) ) { Nd4j . getSparseBlasWrapper ( ) ....
performs rotation of points in the plane .
19,905
public void rotmg ( INDArray d1 , INDArray d2 , INDArray b1 , double b2 , INDArray P ) { throw new UnsupportedOperationException ( ) ; }
computes the modified parameters for a Givens rotation .
19,906
public void scal ( long N , double alpha , INDArray X ) { if ( Nd4j . getExecutioner ( ) . getProfilingMode ( ) == OpExecutioner . ProfilingMode . ALL ) OpProfiler . getInstance ( ) . processBlasCall ( false , X ) ; if ( X . isSparse ( ) ) { Nd4j . getSparseBlasWrapper ( ) . level1 ( ) . scal ( N , alpha , X ) ; } else...
computes a vector by a scalar product .
19,907
public INDArray asRowVector ( BufferedImage image ) { if ( centerCropIfNeeded ) { image = centerCropIfNeeded ( image ) ; } image = scalingIfNeed ( image , true ) ; if ( channels == 3 ) { return toINDArrayBGR ( image ) . ravel ( ) ; } int [ ] [ ] ret = toIntArrayArray ( image ) ; return NDArrayUtil . toNDArray ( ArrayUt...
Convert an image in to a row vector
19,908
public INDArray toRaveledTensor ( BufferedImage image ) { try { image = scalingIfNeed ( image , false ) ; return toINDArrayBGR ( image ) . ravel ( ) ; } catch ( Exception e ) { throw new RuntimeException ( "Unable to load image" , e ) ; } }
Convert an image in to a raveled tensor of the bgr values of the image
19,909
public INDArray toBgr ( BufferedImage image ) { if ( image == null ) throw new IllegalStateException ( "Unable to load image" ) ; image = scalingIfNeed ( image , false ) ; return toINDArrayBGR ( image ) ; }
Convert an BufferedImage to an bgr spectrum image
19,910
public INDArray asMatrix ( InputStream inputStream ) throws IOException { if ( channels == 3 ) return toBgr ( inputStream ) ; try { BufferedImage image = ImageIO . read ( inputStream ) ; return asMatrix ( image ) ; } catch ( IOException e ) { throw new IOException ( "Unable to load image" , e ) ; } }
Convert an input stream to a matrix
19,911
public INDArray asMatrix ( BufferedImage image ) { if ( channels == 3 ) { return toBgr ( image ) ; } else { image = scalingIfNeed ( image , true ) ; int w = image . getWidth ( ) ; int h = image . getHeight ( ) ; INDArray ret = Nd4j . create ( h , w ) ; for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ )...
Convert an BufferedImage to a matrix
19,912
public INDArray asImageMiniBatches ( File f , int numMiniBatches , int numRowsPerSlice ) { try { INDArray d = asMatrix ( f ) ; return Nd4j . create ( numMiniBatches , numRowsPerSlice , d . columns ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Slices up an image in to a mini batch .
19,913
public static BufferedImage toImage ( INDArray matrix ) { BufferedImage img = new BufferedImage ( matrix . rows ( ) , matrix . columns ( ) , BufferedImage . TYPE_INT_ARGB ) ; WritableRaster r = img . getRaster ( ) ; int [ ] equiv = new int [ ( int ) matrix . length ( ) ] ; for ( int i = 0 ; i < equiv . length ; i ++ ) ...
Convert a matrix in to a buffereed image
19,914
public static Column mean ( DataRowsFacade dataFrame , String columnName ) { return dataFrame . get ( ) . groupBy ( columnName ) . agg ( avg ( columnName ) ) . col ( columnName ) ; }
Mean for a column
19,915
public static StructType fromSchema ( Schema schema ) { StructField [ ] structFields = new StructField [ schema . numColumns ( ) ] ; for ( int i = 0 ; i < structFields . length ; i ++ ) { switch ( schema . getColumnTypes ( ) . get ( i ) ) { case Double : structFields [ i ] = new StructField ( schema . getName ( i ) , D...
Convert a datavec schema to a struct type in spark
19,916
public static Schema fromStructType ( StructType structType ) { Schema . Builder builder = new Schema . Builder ( ) ; StructField [ ] fields = structType . fields ( ) ; String [ ] fieldNames = structType . fieldNames ( ) ; for ( int i = 0 ; i < fields . length ; i ++ ) { String name = fields [ i ] . dataType ( ) . type...
Create a datavec schema from a struct type
19,917
public static Pair < Schema , JavaRDD < List < Writable > > > toRecords ( DataRowsFacade dataFrame ) { Schema schema = fromStructType ( dataFrame . get ( ) . schema ( ) ) ; return new Pair < > ( schema , dataFrame . get ( ) . javaRDD ( ) . map ( new ToRecord ( schema ) ) ) ; }
Create a compatible schema and rdd for datavec
19,918
public static DataRowsFacade toDataFrame ( Schema schema , JavaRDD < List < Writable > > data ) { JavaSparkContext sc = new JavaSparkContext ( data . context ( ) ) ; SQLContext sqlContext = new SQLContext ( sc ) ; JavaRDD < Row > rows = data . map ( new ToRow ( schema ) ) ; return dataRows ( sqlContext . createDataFram...
Creates a data frame from a collection of writables rdd given a schema
19,919
public static List < Writable > rowToWritables ( Schema schema , Row row ) { List < Writable > ret = new ArrayList < > ( ) ; for ( int i = 0 ; i < row . size ( ) ; i ++ ) { switch ( schema . getType ( i ) ) { case Double : ret . add ( new DoubleWritable ( row . getDouble ( i ) ) ) ; break ; case Float : ret . add ( new...
Convert a given Row to a list of writables given the specified Schema
19,920
public static List < String > toList ( String [ ] input ) { List < String > ret = new ArrayList < > ( ) ; for ( int i = 0 ; i < input . length ; i ++ ) ret . add ( input [ i ] ) ; return ret ; }
Convert a string array into a list
19,921
public static String [ ] toArray ( List < String > list ) { String [ ] ret = new String [ list . size ( ) ] ; for ( int i = 0 ; i < ret . length ; i ++ ) ret [ i ] = list . get ( i ) ; return ret ; }
Convert a string list into a array
19,922
public static INDArray toMatrix ( List < Row > rows ) { INDArray ret = Nd4j . create ( rows . size ( ) , rows . get ( 0 ) . size ( ) ) ; for ( int i = 0 ; i < ret . rows ( ) ; i ++ ) { for ( int j = 0 ; j < ret . columns ( ) ; j ++ ) { ret . putScalar ( i , j , rows . get ( i ) . getDouble ( j ) ) ; } } return ret ; }
Convert a list of rows to a matrix
19,923
public static List < Column > toColumn ( List < String > columns ) { List < Column > ret = new ArrayList < > ( ) ; for ( String s : columns ) ret . add ( col ( s ) ) ; return ret ; }
Convert a list of string names to columns
19,924
public static Column [ ] toColumns ( String ... columns ) { Column [ ] ret = new Column [ columns . length ] ; for ( int i = 0 ; i < columns . length ; i ++ ) ret [ i ] = col ( columns [ i ] ) ; return ret ; }
Convert an array of strings to column names
19,925
public int compareTo ( Object o ) { float thisValue = this . value ; float thatValue = ( ( FloatWritable ) o ) . value ; return ( thisValue < thatValue ? - 1 : ( thisValue == thatValue ? 0 : 1 ) ) ; }
Compares two FloatWritables .
19,926
private static long getUpdateFrequencyConfiguration ( ) { String property = System . getProperty ( DL4JSystemProperties . NTP_SOURCE_UPDATE_FREQUENCY_MS_PROPERTY ) ; Long parseAttempt = null ; long updateFreq ; if ( property != null ) { try { parseAttempt = Long . parseLong ( property ) ; } catch ( Exception e ) { log ...
Query and parse the system property
19,927
private INDArray gaussianRandomMatrix ( long [ ] shape , Random rng ) { Nd4j . checkShapeValues ( shape ) ; INDArray res = Nd4j . create ( shape ) ; GaussianDistribution op1 = new GaussianDistribution ( res , 0.0 , 1.0 / Math . sqrt ( shape [ 0 ] ) ) ; Nd4j . getExecutioner ( ) . exec ( op1 , rng ) ; return res ; }
Generate a dense Gaussian random matrix .
19,928
private double getEpsFromConfig ( Map < String , Object > layerConfig ) throws InvalidKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; if ( ! innerConfig . containsKey ( LAYER_FIELD_EPSILON ) ) throw new InvalidKerasConfiguratio...
Get BatchNormalization epsilon parameter from Keras layer configuration .
19,929
private double getMomentumFromConfig ( Map < String , Object > layerConfig ) throws InvalidKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; if ( ! innerConfig . containsKey ( LAYER_FIELD_MOMENTUM ) ) throw new InvalidKerasConfig...
Get BatchNormalization momentum parameter from Keras layer configuration .
19,930
private void getGammaRegularizerFromConfig ( Map < String , Object > layerConfig , boolean enforceTrainingConfig ) throws UnsupportedKerasConfigurationException , InvalidKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; if ( inne...
Get BatchNormalization gamma regularizer from Keras layer configuration . Currently unsupported .
19,931
private void getBetaRegularizerFromConfig ( Map < String , Object > layerConfig , boolean enforceTrainingConfig ) throws UnsupportedKerasConfigurationException , InvalidKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; if ( inner...
Get BatchNormalization beta regularizer from Keras layer configuration . Currently unsupported .
19,932
private int getBatchNormMode ( Map < String , Object > layerConfig , boolean enforceTrainingConfig ) throws InvalidKerasConfigurationException , UnsupportedKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; int batchNormMode = 0 ;...
Get BatchNormalization mode from Keras layer configuration . Most modes currently unsupported .
19,933
private int getBatchNormAxis ( Map < String , Object > layerConfig ) throws InvalidKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; return ( int ) innerConfig . get ( LAYER_FIELD_AXIS ) ; }
Get BatchNormalization axis from Keras layer configuration . Currently unused .
19,934
public int compareTo ( Object o ) { int thisValue = this . value ; int thatValue = ( ( IntWritable ) o ) . value ; return ( thisValue < thatValue ? - 1 : ( thisValue == thatValue ? 0 : 1 ) ) ; }
Compares two IntWritables .
19,935
public Sequence < T > nextSequence ( ) { Sequence < T > sequence = currentIterator . next ( ) ; sequence . setSequenceId ( tagger . getAndIncrement ( ) ) ; return sequence ; }
Returns next sequence out of iterator
19,936
public static void validateConvolutionModePadding ( ConvolutionMode mode , int padding ) { if ( mode == ConvolutionMode . Same ) { boolean nullPadding = true ; if ( padding != 0 ) nullPadding = false ; if ( ! nullPadding ) throw new IllegalArgumentException ( "Padding cannot be used when using the `same' convolution mo...
Check that the convolution mode is consistent with the padding specification
19,937
public static int getSameModeTopLeftPadding ( int outSize , int inSize , int kernel , int strides , int dilation ) { int eKernel = effectiveKernelSize ( kernel , dilation ) ; int outPad = ( ( outSize - 1 ) * strides + eKernel - inSize ) / 2 ; Preconditions . checkState ( outPad >= 0 , "Invalid padding values calculated...
Get top padding for same mode only .
19,938
public boolean validateEvent ( ListenerEvent event , long argument ) { try { locker . acquire ( ) ; if ( event == targetEvent && argument % targetFrequency == 0 ) { return true ; } else return false ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } finally { locker . release ( ) ; } }
This method is called prior each processEvent call to check if this specific VectorsListener implementation is viable for specific event
19,939
public void processEvent ( ListenerEvent event , SequenceVectors < T > sequenceVectors , long argument ) { try { locker . acquire ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy-MM-dd HH:mm:ss.SSS" ) ; StringBuilder builder = new StringBuilder ( targetFolder . getAbsolutePath ( ) ) ; builder . append ( "/" ) ...
This method is called at each epoch end
19,940
public static INDArray [ ] arraysFromBase64 ( String base64 ) throws IOException { String [ ] base64Arr = base64 . split ( "\t" ) ; INDArray [ ] ret = new INDArray [ base64Arr . length ] ; for ( int i = 0 ; i < base64Arr . length ; i ++ ) { byte [ ] decode = Base64 . decodeBase64 ( base64Arr [ i ] ) ; ByteArrayInputStr...
Returns a set of arrays from base 64 that is tab delimited .
19,941
public static String arraysToBase64 ( INDArray [ ] arrays ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; for ( INDArray outputArr : arrays ) { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; DataOutputStream dos = new DataOutputStream ( bos ) ; Nd4j . write ( outputArr , dos ) ; String ba...
Returns a tab delimited base 64 representation of the given arrays
19,942
public static String base64String ( INDArray arr ) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; DataOutputStream dos = new DataOutputStream ( bos ) ; Nd4j . write ( arr , dos ) ; String base64 = Base64 . encodeBase64String ( bos . toByteArray ( ) ) ; return base64 ; }
Returns an ndarray as base 64
19,943
public static INDArray fromBase64 ( String base64 ) throws IOException { byte [ ] arr = Base64 . decodeBase64 ( base64 ) ; ByteArrayInputStream bis = new ByteArrayInputStream ( arr ) ; DataInputStream dis = new DataInputStream ( bis ) ; INDArray predict = Nd4j . read ( dis ) ; return predict ; }
Create an ndarray from a base 64 representation
19,944
public static INDArray generate ( long [ ] shape , Values values ) { return generate ( shape , Nd4j . order ( ) , values ) ; }
Generate a random array with the specified shape
19,945
protected INDArray createBias ( NeuralNetConfiguration conf , INDArray biasView , boolean initializeParams ) { org . deeplearning4j . nn . conf . layers . ConvolutionLayer layerConf = ( org . deeplearning4j . nn . conf . layers . ConvolutionLayer ) conf . getLayer ( ) ; if ( initializeParams ) biasView . assign ( layer...
1 bias per feature map
19,946
public Map < String , Number > status ( ) { Map < String , Number > ret = new HashMap < > ( ) ; ret . put ( "workers" , workers ) ; ret . put ( "accumulatedUpdates" , numUpdates ( ) ) ; return ret ; }
Returns the current status of this parameter server updater
19,947
public String toJson ( ) { try { return objectMapper . writeValueAsString ( status ( ) ) ; } catch ( JsonProcessingException e ) { throw new RuntimeException ( e ) ; } }
Serialize this updater as json
19,948
public void update ( NDArrayMessage message ) { updateStorage . addUpdate ( message ) ; INDArray arr = message . getArr ( ) ; int [ ] dimensions = message . getDimensions ( ) ; boolean whole = dimensions . length == 1 && dimensions [ 0 ] == - 1 ; if ( ! whole ) partialUpdate ( arr , ndArrayHolder . get ( ) , message . ...
Do an update based on the ndarray message .
19,949
public LabelledDocument nextDocument ( ) { LabelledDocument document = currentIterator . next ( ) ; for ( String label : document . getLabels ( ) ) { labels . storeLabel ( label ) ; } return document ; }
This method returns next LabelledDocument from underlying iterator
19,950
public void queueReport ( WebTarget target , Entity entity ) { queue . add ( Pair . makePair ( target , entity ) ) ; }
This method queues UI report for sending
19,951
public void postReport ( WebTarget target , Entity entity ) { Response resp = target . request ( MediaType . APPLICATION_JSON ) . accept ( MediaType . APPLICATION_JSON ) . post ( entity ) ; log . debug ( "{}" , resp ) ; }
This method immediately sends UI report to specified target using POST request
19,952
public static < K , T , V > MultiDimensionalMap < K , T , V > newThreadSafeTreeBackedMap ( ) { return new MultiDimensionalMap < > ( new ConcurrentSkipListMap < Pair < K , T > , V > ( ) ) ; }
Thread safe sorted map implementation
19,953
public static < K , T , V > MultiDimensionalMap < K , T , V > newThreadSafeHashBackedMap ( ) { return new MultiDimensionalMap < > ( new ConcurrentHashMap < Pair < K , T > , V > ( ) ) ; }
Thread safe hash map implementation
19,954
public static < K , T , V > MultiDimensionalMap < K , T , V > newHashBackedMap ( ) { return new MultiDimensionalMap < > ( new HashMap < Pair < K , T > , V > ( ) ) ; }
Thread safe hash map impl
19,955
public static < K , T , V > MultiDimensionalMap < K , T , V > newTreeBackedMap ( ) { return new MultiDimensionalMap < > ( new TreeMap < Pair < K , T > , V > ( ) ) ; }
Tree map implementation
19,956
public INDArray getRange ( ) { if ( range == null ) { try ( MemoryWorkspace ws = Nd4j . getMemoryManager ( ) . scopeOutOfWorkspaces ( ) ) { range = upper . sub ( lower ) ; } } return range ; }
Get the feature wise range for the statistics . Note that this is a lazy getter . It is only computed when needed .
19,957
public INDArray average ( INDArray target , INDArray [ ] arrays ) { if ( arrays == null || arrays . length == 0 ) throw new RuntimeException ( "Input arrays are missing" ) ; if ( arrays . length == 1 ) { if ( target == null ) { return null ; } return target . assign ( arrays [ 0 ] ) ; } long len = target != null ? targ...
This method averages input arrays and returns averaged array
19,958
public static int numChunksForMessage ( NDArrayMessage message , int chunkSize ) { int sizeOfMessage = NDArrayMessage . byteBufferSizeForMessage ( message ) ; int numMessages = sizeOfMessage / chunkSize ; if ( numMessages * chunkSize < sizeOfMessage ) numMessages ++ ; return numMessages ; }
Determine the number of chunks
19,959
public static NDArrayMessage [ ] chunkedMessages ( NDArrayMessage arrayMessage , int chunkSize ) { int sizeOfMessage = NDArrayMessage . byteBufferSizeForMessage ( arrayMessage ) - 4 ; int numMessages = sizeOfMessage / chunkSize ; ByteBuffer direct = NDArrayMessage . toBuffer ( arrayMessage ) . byteBuffer ( ) ; NDArrayM...
Create an array of messages to send based on a specified chunk size
19,960
public static long getCurrentTimeUtc ( ) { Instant instant = Instant . now ( ) ; ZonedDateTime dateTime = instant . atZone ( ZoneOffset . UTC ) ; return dateTime . toInstant ( ) . toEpochMilli ( ) ; }
Get the current time in utc in milliseconds
19,961
public void trackStatePointer ( NativePack random ) { if ( random . getStatePointer ( ) != null ) { GarbageStateReference reference = new GarbageStateReference ( random , queue ) ; referenceMap . put ( random . getStatePointer ( ) . address ( ) , reference ) ; } }
This method is used internally from NativeRandom deallocators This method doesn t accept Random interface implementations intentionally .
19,962
public void relocate ( AllocationStatus currentStatus , AllocationStatus targetStatus , AllocationPoint point , AllocationShape shape , CudaContext context ) { if ( currentStatus == AllocationStatus . DEVICE && targetStatus == AllocationStatus . HOST ) { DataBuffer targetBuffer = point . getBuffer ( ) ; if ( targetBuff...
Copies specific chunk of memory from one storage to another
19,963
public void copyforward ( AllocationPoint point , AllocationShape shape ) { log . info ( "copyforward() called on tp[" + point . getObjectId ( ) + "], shape: " + point . getShape ( ) ) ; throw new UnsupportedOperationException ( "Deprecated call" ) ; }
Copies memory from host buffer to device . Host copy is preserved as is .
19,964
public void fallback ( AllocationPoint point , AllocationShape shape ) { throw new IllegalStateException ( "Can't fallback from [" + point . getAllocationStatus ( ) + "]" ) ; }
Copies memory from device to zero - copy memory
19,965
public void free ( AllocationPoint point , AllocationStatus target ) { if ( point . getAllocationStatus ( ) == AllocationStatus . DEVICE ) deviceMemoryTracker . subFromAllocation ( Thread . currentThread ( ) . getId ( ) , point . getDeviceId ( ) , AllocationUtils . getRequiredMemory ( point . getShape ( ) ) ) ; memoryP...
This method frees memory chunk specified by pointer and location
19,966
public void memcpyAsync ( DataBuffer dstBuffer , Pointer srcPointer , long length , long dstOffset ) { AllocationPoint point = ( ( BaseCudaDataBuffer ) dstBuffer ) . getAllocationPoint ( ) ; Pointer dP = new CudaPointer ( ( point . getPointers ( ) . getHostPointer ( ) . address ( ) ) + dstOffset ) ; CudaContext tContex...
Asynchronous version of memcpy
19,967
public void memcpySpecial ( DataBuffer dstBuffer , Pointer srcPointer , long length , long dstOffset ) { CudaContext context = getCudaContext ( ) ; AllocationPoint point = ( ( BaseCudaDataBuffer ) dstBuffer ) . getAllocationPoint ( ) ; Pointer dP = new CudaPointer ( ( point . getPointers ( ) . getHostPointer ( ) . addr...
Special memcpy version addressing shapeInfoDataBuffer copies
19,968
public boolean promoteObject ( DataBuffer buffer ) { AllocationPoint dstPoint = AtomicAllocator . getInstance ( ) . getAllocationPoint ( buffer ) ; if ( dstPoint . getAllocationStatus ( ) != AllocationStatus . HOST ) return false ; if ( configuration . getMemoryModel ( ) == Configuration . MemoryModel . DELAYED && dstP...
This method moves specific object from zero - copy memory to device memory
19,969
public Table < AllocationStatus , Integer , Long > getAllocationStatistics ( ) { Table < AllocationStatus , Integer , Long > table = HashBasedTable . create ( ) ; table . put ( AllocationStatus . HOST , 0 , zeroUseCounter . get ( ) ) ; for ( Integer deviceId : configuration . getAvailableDevices ( ) ) { table . put ( A...
This method returns total amount of memory allocated within system
19,970
public long getAllocatedHostObjects ( Long bucketId ) { if ( zeroAllocations . containsKey ( bucketId ) ) return zeroAllocations . get ( bucketId ) . size ( ) ; else return 0L ; }
This method returns number of allocated objects within specific bucket
19,971
public long getAllocatedHostObjects ( ) { AtomicLong counter = new AtomicLong ( 0 ) ; for ( Long threadId : zeroAllocations . keySet ( ) ) { counter . addAndGet ( zeroAllocations . get ( threadId ) . size ( ) ) ; } return counter . get ( ) ; }
This method returns total number of allocated objects in host memory
19,972
public Set < Long > getDeviceTrackingPoints ( Integer deviceId ) { return deviceAllocations . get ( deviceId ) . keySet ( ) ; }
This method returns set of allocation tracking IDs for specific device
19,973
public Set < Long > getHostTrackingPoints ( Long bucketId ) { if ( ! zeroAllocations . containsKey ( bucketId ) ) { return new HashSet < > ( ) ; } return zeroAllocations . get ( bucketId ) . keySet ( ) ; }
This method returns sets of allocation tracking IDs for specific bucket
19,974
public void purgeDeviceObject ( Long threadId , Integer deviceId , Long objectId , AllocationPoint point , boolean copyback ) { if ( point . getAllocationStatus ( ) != AllocationStatus . DEVICE ) return ; flowController . waitTillReleased ( point ) ; free ( point , AllocationStatus . DEVICE ) ; if ( ! deviceAllocations...
This method explicitly removes object from device memory .
19,975
public void purgeZeroObject ( Long bucketId , Long objectId , AllocationPoint point , boolean copyback ) { forget ( point , AllocationStatus . HOST ) ; flowController . waitTillReleased ( point ) ; free ( point , AllocationStatus . HOST ) ; point . setAllocationStatus ( AllocationStatus . DEALLOCATED ) ; long reqMem = ...
This method explicitly removes object from zero - copy memory .
19,976
protected void initCudaContextForThread ( Long threadId ) { nativeOps . setDevice ( getDeviceId ( ) ) ; CudaContext context = new CudaContext ( ) ; context . initHandle ( ) ; context . initOldStream ( ) ; context . initStream ( ) ; context . associateHandle ( ) ; }
This method does initialization for thread .
19,977
public void synchronizeThreadDevice ( Long threadId , Integer deviceId , AllocationPoint point ) { flowController . synchronizeToHost ( point ) ; }
This method causes memory synchronization on host side . Viable only for Device - dependant MemoryHandlers
19,978
private static void setJobConf ( Object theObject , Configuration conf ) { try { Class < ? > jobConfClass = conf . getClassByName ( "org.apache.hadoop.mapred.JobConf" ) ; Class < ? > jobConfigurableClass = conf . getClassByName ( "org.apache.hadoop.mapred.JobConfigurable" ) ; if ( jobConfClass . isAssignableFrom ( conf...
This code is to support backward compatibility and break the compile time dependency of core on mapred . This should be made deprecated along with the mapred package HADOOP - 1230 . Should be removed when mapred package is removed .
19,979
@ SuppressWarnings ( "unchecked" ) public static < T > T copy ( Configuration conf , T src , T dst ) throws IOException { CopyInCopyOutBuffer buffer = cloneBuffers . get ( ) ; buffer . outBuffer . reset ( ) ; SerializationFactory factory = getFactory ( conf ) ; Class < T > cls = ( Class < T > ) src . getClass ( ) ; Ser...
Make a copy of the writable object using serialization to a buffer
19,980
public static < K , V > Map < K , Pair < List < V > , List < V > > > cogroup ( List < Pair < K , V > > left , List < Pair < K , V > > right ) { Map < K , Pair < List < V > , List < V > > > ret = new HashMap < > ( ) ; Map < K , List < V > > leftMap = groupByKey ( left ) ; Map < K , List < V > > rightMap = groupByKey ( r...
For each key in left and right cogroup returns the list of values as a pair for each value present in left as well as right .
19,981
public static < K , V > Map < K , List < V > > groupByKey ( List < Pair < K , V > > listInput ) { Map < K , List < V > > ret = new HashMap < > ( ) ; for ( Pair < K , V > pair : listInput ) { List < V > currList = ret . get ( pair . getFirst ( ) ) ; if ( currList == null ) { currList = new ArrayList < > ( ) ; ret . put ...
Group the input pairs by the key of each pair .
19,982
public OpDef getOpDefByTensorflowName ( String name ) { if ( ! tensorflowOpDescriptors . containsKey ( name ) ) { throw new ND4JIllegalStateException ( "No op found with name " + name ) ; } return tensorflowOpDescriptors . get ( name ) ; }
Get the op definition of a given tensorflow op .
19,983
public boolean storeIfAbsent ( T key , INDArray object ) { try { if ( emulateIsAbsent ) lock . writeLock ( ) . lock ( ) ; if ( compressedEntries . containsKey ( key ) ) { return false ; } else { store ( key , object ) ; return true ; } } finally { if ( emulateIsAbsent ) lock . writeLock ( ) . unlock ( ) ; } }
Store object into storage if it doesn t exist
19,984
public INDArray get ( T key ) { try { if ( emulateIsAbsent ) lock . readLock ( ) . lock ( ) ; if ( containsKey ( key ) ) { INDArray result = compressedEntries . get ( key ) ; return compressor . decompress ( result ) ; } else { return null ; } } finally { if ( emulateIsAbsent ) lock . readLock ( ) . unlock ( ) ; } }
Get object from the storage by key
19,985
public boolean containsKey ( T key ) { try { if ( emulateIsAbsent ) lock . readLock ( ) . lock ( ) ; return compressedEntries . containsKey ( key ) ; } finally { if ( emulateIsAbsent ) lock . readLock ( ) . unlock ( ) ; } }
This method checks if storage contains specified key
19,986
public void clear ( ) { if ( emulateIsAbsent ) lock . writeLock ( ) . lock ( ) ; compressedEntries . clear ( ) ; if ( emulateIsAbsent ) lock . writeLock ( ) . unlock ( ) ; }
This method purges everything from storage
19,987
public void drop ( T key ) { if ( emulateIsAbsent ) lock . writeLock ( ) . lock ( ) ; compressedEntries . remove ( key ) ; if ( emulateIsAbsent ) lock . writeLock ( ) . unlock ( ) ; }
This method removes value by specified key
19,988
public long size ( ) { try { if ( emulateIsAbsent ) lock . readLock ( ) . lock ( ) ; return compressedEntries . size ( ) ; } finally { if ( emulateIsAbsent ) lock . readLock ( ) . unlock ( ) ; } }
This method returns number of entries available in storage
19,989
public synchronized void incrementWordCount ( String word , int increment ) { if ( word == null || word . isEmpty ( ) ) throw new IllegalArgumentException ( "Word can't be empty or null" ) ; wordFrequencies . incrementCount ( word , increment ) ; if ( hasToken ( word ) ) { VocabWord token = tokenFor ( word ) ; token . ...
Increment the count for the given word by the amount increment
19,990
public static double logBinomialProbability ( int x , int n , double p , double q ) { double ret ; if ( x == 0 ) { if ( p < 0.1 ) { ret = - getDeviancePart ( n , n * q ) - n * p ; } else { ret = n * FastMath . log ( q ) ; } } else if ( x == n ) { if ( q < 0.1 ) { ret = - getDeviancePart ( n , n * p ) - n * q ; } else {...
Compute the logarithm of the PMF for a binomial distribution using the saddle point expansion .
19,991
private String formatPointer ( PatriciaTrie . PatriciaNode < V > from , PatriciaTrie . PatriciaNode < V > to , String label , String tailport ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( getNodeId ( from ) ) ; builder . append ( " -> " ) ; builder . append ( getNodeId ( to ) ) ; builder . appe...
Formats a link between two nodes
19,992
private String formatNodeLabel ( PatriciaTrie . PatriciaNode < V > node , KeyMapper < String > keyMapper , boolean formatBitString ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "<<table border=\"0\" cellborder=\"0\">" ) ; builder . append ( "<tr><td>" ) ; builder . append ( "key: <font color=\"...
Format node label
19,993
private String getNodeId ( PatriciaTrie . PatriciaNode < V > node ) { if ( node == null ) { return "null" ; } else { return node . getKey ( ) ; } }
Get node id used to distinguish nodes internally
19,994
public static boolean checkKryoConfiguration ( JavaSparkContext javaSparkContext , Logger log ) { String serializer = javaSparkContext . getConf ( ) . get ( "spark.serializer" , null ) ; if ( serializer != null && serializer . equals ( "org.apache.spark.serializer.KryoSerializer" ) ) { String kryoRegistrator = javaSpar...
Check the spark configuration for incorrect Kryo configuration logging a warning message if necessary
19,995
public static JavaRDD < DataSet > shuffleExamples ( JavaRDD < DataSet > rdd , int newBatchSize , int numPartitions ) { JavaPairRDD < Integer , DataSet > singleExampleDataSets = rdd . flatMapToPair ( new SplitDataSetExamplesPairFlatMapFunction ( numPartitions ) ) ; singleExampleDataSets = singleExampleDataSets . partiti...
Randomly shuffle the examples in each DataSet object and recombine them into new DataSet objects with the specified BatchSize
19,996
protected void pushToGrid ( OpDescriptor descriptor , boolean flush ) { execCounter . incrementAndGet ( ) ; Op op = descriptor . getOp ( ) ; int [ ] dimensions = descriptor . getDimensions ( ) ; if ( op instanceof TransformOp ) { TransformOp t = ( TransformOp ) op ; if ( flush ) flushQueue ( ) ; super . invoke ( t ) ; ...
This method adds op into GridOp queue
19,997
protected boolean isMatchingZX ( Op opA , Op opB ) { if ( opA . x ( ) == opB . x ( ) && opA . z ( ) == opB . z ( ) && opA . x ( ) == opB . z ( ) ) return true ; return false ; }
This method checks if opA and opB are sharing the same operands
19,998
protected boolean isMatchingZXY ( Op opA , Op opB ) { if ( opA . z ( ) == opB . x ( ) || opA . z ( ) == opB . y ( ) ) return true ; return false ; }
This method is additional check basically it qualifies possibility of InvertedPredicate MetaOp
19,999
protected GridPointers pointerizeOp ( Op op , int ... dimensions ) { GridPointers pointers = new GridPointers ( op , dimensions ) ; AtomicAllocator allocator = AtomicAllocator . getInstance ( ) ; CudaContext context = ( CudaContext ) allocator . getDeviceContext ( ) . getContext ( ) ; pointers . setX ( allocator . getP...
This method returns Op as set of required pointers for it