idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
19,500 | public double precision ( Integer classLabel , double edgeCase ) { double tpCount = truePositives . getCount ( classLabel ) ; double fpCount = falsePositives . getCount ( classLabel ) ; return EvaluationUtils . precision ( ( long ) tpCount , ( long ) fpCount , edgeCase ) ; } | Returns the precision for a given label |
19,501 | public double recall ( int classLabel , double edgeCase ) { double tpCount = truePositives . getCount ( classLabel ) ; double fnCount = falseNegatives . getCount ( classLabel ) ; return EvaluationUtils . recall ( ( long ) tpCount , ( long ) fnCount , edgeCase ) ; } | Returns the recall for a given label |
19,502 | public double falsePositiveRate ( int classLabel , double edgeCase ) { double fpCount = falsePositives . getCount ( classLabel ) ; double tnCount = trueNegatives . getCount ( classLabel ) ; return EvaluationUtils . falsePositiveRate ( ( long ) fpCount , ( long ) tnCount , edgeCase ) ; } | Returns the false positive rate for a given label |
19,503 | public double falsePositiveRate ( EvaluationAveraging averaging ) { int nClasses = confusion ( ) . getClasses ( ) . size ( ) ; if ( averaging == EvaluationAveraging . Macro ) { double macroFPR = 0.0 ; for ( int i = 0 ; i < nClasses ; i ++ ) { macroFPR += falsePositiveRate ( i ) ; } macroFPR /= nClasses ; return macroFP... | Calculate the average false positive rate across all classes . Can specify whether macro or micro averaging should be used |
19,504 | public double falseNegativeRate ( EvaluationAveraging averaging ) { int nClasses = confusion ( ) . getClasses ( ) . size ( ) ; if ( averaging == EvaluationAveraging . Macro ) { double macroFNR = 0.0 ; for ( int i = 0 ; i < nClasses ; i ++ ) { macroFNR += falseNegativeRate ( i ) ; } macroFNR /= nClasses ; return macroFN... | Calculate the average false negative rate for all classes - can specify whether macro or micro averaging should be used |
19,505 | public double fBeta ( double beta , EvaluationAveraging averaging ) { if ( getNumRowCounter ( ) == 0.0 ) { return Double . NaN ; } int nClasses = confusion ( ) . getClasses ( ) . size ( ) ; if ( nClasses == 2 ) { return EvaluationUtils . fBeta ( beta , ( long ) truePositives . getCount ( 1 ) , ( long ) falsePositives .... | Calculate the average F_beta score across all classes using macro or micro averaging |
19,506 | public double gMeasure ( EvaluationAveraging averaging ) { int nClasses = confusion ( ) . getClasses ( ) . size ( ) ; if ( averaging == EvaluationAveraging . Macro ) { double macroGMeasure = 0.0 ; for ( int i = 0 ; i < nClasses ; i ++ ) { macroGMeasure += gMeasure ( i ) ; } macroGMeasure /= nClasses ; return macroGMeas... | Calculates the average G measure for all outputs using micro or macro averaging |
19,507 | public void merge ( Evaluation other ) { if ( other == null ) return ; truePositives . incrementAll ( other . truePositives ) ; falsePositives . incrementAll ( other . falsePositives ) ; trueNegatives . incrementAll ( other . trueNegatives ) ; falseNegatives . incrementAll ( other . falseNegatives ) ; if ( confusion ==... | Merge the other evaluation object into this one . The result is that this Evaluation instance contains the counts etc from both |
19,508 | public String confusionToString ( ) { int nClasses = confusion ( ) . getClasses ( ) . size ( ) ; int maxLabelSize = 0 ; for ( String s : labelsList ) { maxLabelSize = Math . max ( maxLabelSize , s . length ( ) ) ; } int labelSize = Math . max ( maxLabelSize + 5 , 10 ) ; StringBuilder sb = new StringBuilder ( ) ; sb . a... | Get a String representation of the confusion matrix |
19,509 | public MultiLayerConfiguration getMultiLayerConfiguration ( ) throws InvalidKerasConfigurationException , UnsupportedKerasConfigurationException { if ( ! this . className . equals ( config . getFieldClassNameSequential ( ) ) ) throw new InvalidKerasConfigurationException ( "Keras model class name " + this . className +... | Configure a MultiLayerConfiguration from this Keras Sequential model configuration . |
19,510 | public MultiLayerNetwork getMultiLayerNetwork ( boolean importWeights ) throws InvalidKerasConfigurationException , UnsupportedKerasConfigurationException { MultiLayerNetwork model = new MultiLayerNetwork ( getMultiLayerConfiguration ( ) ) ; model . init ( ) ; if ( importWeights ) model = ( MultiLayerNetwork ) KerasMod... | Build a MultiLayerNetwork from this Keras Sequential model configuration and import weights . |
19,511 | public long [ ] lookup ( int index ) { if ( exists [ index ] ) { return indexes [ index ] ; } else { exists [ index ] = true ; indexes [ index ] = ordering == 'c' ? Shape . ind2subC ( shape , index , numIndexes ) : Shape . ind2sub ( shape , index , numIndexes ) ; return indexes [ index ] ; } } | Give back a sub wrt the given linear index |
19,512 | public static Op . Type getTypeFromByte ( byte type ) { switch ( type ) { case OpType . SCALAR : return Op . Type . SCALAR ; case OpType . SCALAR_BOOL : return Op . Type . SCALAR_BOOL ; case OpType . BROADCAST : return Op . Type . BROADCAST ; case OpType . BROADCAST_BOOL : return Op . Type . BROADCAST_BOOL ; case OpTyp... | This method converts enums for Op . Type |
19,513 | public static byte getFlatOpType ( Op . Type type ) { switch ( type ) { case SCALAR : return OpType . SCALAR ; case SCALAR_BOOL : return OpType . SCALAR_BOOL ; case BROADCAST : return OpType . BROADCAST ; case BROADCAST_BOOL : return OpType . BROADCAST_BOOL ; case TRANSFORM_BOOL : return OpType . TRANSFORM_BOOL ; case ... | This method converts an Op . Type to it s corresponding byte value |
19,514 | public static ByteOrder getOrderFromByte ( byte val ) { if ( val == org . nd4j . graph . ByteOrder . LE ) return ByteOrder . LITTLE_ENDIAN ; else return ByteOrder . BIG_ENDIAN ; } | This method just converts enums |
19,515 | public static byte getOrderAsByte ( ) { if ( ByteOrder . nativeOrder ( ) . equals ( ByteOrder . BIG_ENDIAN ) ) return org . nd4j . graph . ByteOrder . BE ; else return org . nd4j . graph . ByteOrder . LE ; } | This method returns current byte order for this JVM as libnd4j enum |
19,516 | public static ByteBuffer toBuffer ( NDArrayMessageChunk chunk ) { ByteBuffer ret = ByteBuffer . allocateDirect ( sizeForMessage ( chunk ) ) . order ( ByteOrder . nativeOrder ( ) ) ; ret . putInt ( chunk . getMessageType ( ) . ordinal ( ) ) ; ret . putInt ( chunk . getNumChunks ( ) ) ; ret . putInt ( chunk . getChunkSiz... | Convert an ndarray message chunk to a buffer . |
19,517 | public static List < String > tarGzListFiles ( File tarGzFile ) throws IOException { try ( TarArchiveInputStream tin = new TarArchiveInputStream ( new GZIPInputStream ( new BufferedInputStream ( new FileInputStream ( tarGzFile ) ) ) ) ) { ArchiveEntry entry ; List < String > out = new ArrayList < > ( ) ; while ( ( entr... | List all of the files and directories in the specified tar . gz file |
19,518 | public static List < String > zipListFiles ( File zipFile ) throws IOException { List < String > out = new ArrayList < > ( ) ; try ( ZipFile zf = new ZipFile ( zipFile ) ) { Enumeration entries = zf . entries ( ) ; while ( entries . hasMoreElements ( ) ) { ZipEntry ze = ( ZipEntry ) entries . nextElement ( ) ; out . ad... | List all of the files and directories in the specified . zip file |
19,519 | public static void zipExtractSingleFile ( File zipFile , File destination , String pathInZip ) throws IOException { try ( ZipFile zf = new ZipFile ( zipFile ) ; InputStream is = new BufferedInputStream ( zf . getInputStream ( zf . getEntry ( pathInZip ) ) ) ; OutputStream os = new BufferedOutputStream ( new FileOutputS... | Extract a single file from a . zip file . Does not support directories |
19,520 | public static String validate ( OpTestCase testCase ) { collectCoverageInformation ( testCase ) ; List < LongShapeDescriptor > outShapes ; try { outShapes = Nd4j . getExecutioner ( ) . calculateOutputShape ( testCase . op ( ) ) ; } catch ( Throwable t ) { throw new IllegalStateException ( "Error calculating output shap... | Validate the outputs of a single op |
19,521 | private static Set < String > excludeFromTfImportCoverage ( ) { List < String > list = Arrays . asList ( "Reverse" , "LogSigmoid" , "HardSigmoid" , "SpaceToBatch" , "BatchToSpace" , "Pad" , "TopK" , "InTopK" , "BatchMatrixDeterminant" , "BatchMatrixDiagPart" , "BatchMatrixDiag" , "BatchMatrixBandPart" , "BatchMatrixInv... | These ops are excluded from TF import test coverage for various reasons |
19,522 | public static MultiDataSet toMultiDataSet ( DataSet dataSet ) { INDArray f = dataSet . getFeatures ( ) ; INDArray l = dataSet . getLabels ( ) ; INDArray fMask = dataSet . getFeaturesMaskArray ( ) ; INDArray lMask = dataSet . getLabelsMaskArray ( ) ; INDArray [ ] fNew = f == null ? null : new INDArray [ ] { f } ; INDArr... | Convert a DataSet to the equivalent MultiDataSet |
19,523 | public static Pair < WeightInit , Distribution > getWeightInitFromConfig ( Map < String , Object > layerConfig , String initField , boolean enforceTrainingConfig , KerasLayerConfiguration conf , int kerasMajorVersion ) throws InvalidKerasConfigurationException , UnsupportedKerasConfigurationException { Map < String , O... | Get weight initialization from Keras layer configuration . |
19,524 | protected void shardMessageHandler ( DirectBuffer buffer , int offset , int length , Header header ) { byte [ ] data = new byte [ length ] ; buffer . getBytes ( offset , data ) ; VoidMessage message = VoidMessage . fromBytes ( data ) ; if ( message . getMessageType ( ) == 7 ) { messages . add ( message ) ; } else { pub... | This message handler is responsible for receiving messages on Shard side |
19,525 | protected void internalMessageHandler ( DirectBuffer buffer , int offset , int length , Header header ) { byte [ ] data = new byte [ length ] ; buffer . getBytes ( offset , data ) ; VoidMessage message = VoidMessage . fromBytes ( data ) ; messages . add ( message ) ; } | This message handler is responsible for receiving coordination messages on Shard side |
19,526 | protected void clientMessageHandler ( DirectBuffer buffer , int offset , int length , Header header ) { byte [ ] data = new byte [ length ] ; buffer . getBytes ( offset , data ) ; MeaningfulMessage message = ( MeaningfulMessage ) VoidMessage . fromBytes ( data ) ; completed . put ( message . getTaskId ( ) , message ) ;... | This message handler is responsible for receiving messages on Client side |
19,527 | public void init ( VoidConfiguration voidConfiguration , Clipboard clipboard , NodeRole role , String localIp , int localPort , short shardIndex ) { } | This method does initialization of Transport instance |
19,528 | public void shutdown ( ) { runner . set ( false ) ; try { threadA . join ( ) ; if ( threadB != null ) threadB . join ( ) ; } catch ( Exception e ) { } CloseHelper . quietClose ( driver ) ; try { Thread . sleep ( 500 ) ; } catch ( Exception e ) { } } | This method stops transport system . |
19,529 | public void receiveMessage ( VoidMessage message ) { try { log . info ( "Message received, saving..." ) ; messages . put ( message ) ; } catch ( Exception e ) { } } | This method saves incoming message to the Queue for later dispatch from higher - level code like actual TrainingFunction or VoidParameterServer itself |
19,530 | public VoidMessage takeMessage ( ) { if ( threadingModel != ThreadingModel . SAME_THREAD ) { try { return messages . take ( ) ; } catch ( InterruptedException e ) { return null ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } else { if ( subscriptionForShards != null ) subscriptionForShards . poll ( m... | This method takes 1 message from incoming messages queue blocking if queue is empty |
19,531 | protected synchronized void sendCommandToShard ( VoidMessage message ) { if ( nodeRole == NodeRole . SHARD ) { message . setTargetId ( shardIndex ) ; messages . add ( message ) ; return ; } message . setTargetId ( targetIndex ) ; DirectBuffer buffer = message . asUnsafeBuffer ( ) ; long result = publicationForShards . ... | This command is possible to issue only from Client |
19,532 | public Long getTrackingPoint ( ) { if ( underlyingDataBuffer ( ) != this ) return underlyingDataBuffer ( ) == null ? trackingPoint : underlyingDataBuffer ( ) . getTrackingPoint ( ) ; return trackingPoint ; } | Returns tracking point for Allocator |
19,533 | protected QLStepReturn < O > trainStep ( O obs ) { Integer action ; INDArray input = getInput ( obs ) ; boolean isHistoryProcessor = getHistoryProcessor ( ) != null ; if ( isHistoryProcessor ) getHistoryProcessor ( ) . record ( input ) ; int skipFrame = isHistoryProcessor ? getHistoryProcessor ( ) . getConf ( ) . getSk... | Single step of training |
19,534 | public String nextToken ( ) { if ( ! tokens . isEmpty ( ) && position . get ( ) < tokens . size ( ) ) return tokens . get ( position . getAndIncrement ( ) ) ; return nextTokenFromStream ( ) ; } | This method returns next token from prebuffered list of tokens or underlying InputStream |
19,535 | private List < List < Writable > > filterRequiredColumns ( String readerName , List < List < Writable > > list ) { boolean entireReader = false ; List < SubsetDetails > subsetList = null ; int max = - 1 ; int min = Integer . MAX_VALUE ; for ( List < SubsetDetails > sdList : Arrays . asList ( inputs , outputs ) ) { for ... | Filter out the required columns before conversion . This is to avoid trying to convert String etc columns |
19,536 | public void preProcess ( DataSet toPreProcess ) { for ( DataSetPreProcessor preProcessor : preProcessors ) { preProcessor . preProcess ( toPreProcess ) ; } } | Pre process a dataset sequentially |
19,537 | private Result getModelLastUpdateTimes ( String modelIDs ) { if ( currentSessionID == null ) { return ok ( ) ; } StatsStorage ss = knownSessionIDs . get ( currentSessionID ) ; if ( ss == null ) { log . debug ( "getModelLastUpdateTimes(): Session ID is unknown: {}" , currentSessionID ) ; return ok ( "-1" ) ; } String [ ... | Get the last update time for the specified model IDs |
19,538 | public static int [ ] get3DSameModeTopLeftPadding ( int [ ] outSize , int [ ] inSize , int [ ] kernel , int [ ] strides , int [ ] dilation ) { int [ ] eKernel = effectiveKernelSize ( kernel , dilation ) ; int [ ] outPad = new int [ 3 ] ; outPad [ 0 ] = ( ( outSize [ 0 ] - 1 ) * strides [ 0 ] + eKernel [ 0 ] - inSize [ ... | Get top and left padding for same mode only for 3d convolutions |
19,539 | public void purgeBuffers ( ) { log . info ( "Purging TAD buffers..." ) ; tadCache = new ArrayList < > ( ) ; int numDevices = Nd4j . getAffinityManager ( ) . getNumberOfDevices ( ) ; for ( int i = 0 ; i < numDevices ; i ++ ) { log . info ( "Resetting device: [{}]" , i ) ; tadCache . add ( i , new ConcurrentHashMap < Tad... | This method removes all cached shape buffers |
19,540 | public int getLayerSize ( ) { if ( lookupTable != null && lookupTable . getWeights ( ) != null ) { return lookupTable . getWeights ( ) . columns ( ) ; } else return layerSize ; } | This method returns word vector size |
19,541 | public INDArray getWordVectorMatrixNormalized ( String word ) { INDArray r = getWordVectorMatrix ( word ) ; if ( r == null ) return null ; return r . div ( Nd4j . getBlasWrapper ( ) . nrm2 ( r ) ) ; } | Returns the word vector divided by the norm2 of the array |
19,542 | protected void save ( Model model , String filename ) { try { ModelSerializer . writeModel ( model , filename , true ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } | This method saves model |
19,543 | protected QuadTree findIndex ( INDArray coordinates ) { boolean left = ( coordinates . getDouble ( 0 ) <= ( boundary . getX ( ) + boundary . getHw ( ) / 2 ) ) ; boolean top = ( coordinates . getDouble ( 1 ) <= ( boundary . getY ( ) + boundary . getHh ( ) / 2 ) ) ; QuadTree index = getNorthWest ( ) ; if ( left ) { if ( ... | Returns the cell of this element |
19,544 | public boolean insert ( int newIndex ) { INDArray point = data . slice ( newIndex ) ; if ( ! boundary . containsPoint ( point ) ) return false ; cumSize ++ ; double mult1 = ( double ) ( cumSize - 1 ) / ( double ) cumSize ; double mult2 = 1.0 / ( double ) cumSize ; centerOfMass . muli ( mult1 ) ; centerOfMass . addi ( p... | Insert an index of the data in to the tree |
19,545 | public boolean isCorrect ( ) { for ( int n = 0 ; n < size ; n ++ ) { INDArray point = data . slice ( index [ n ] ) ; if ( ! boundary . containsPoint ( point ) ) return false ; } return isLeaf ( ) || northWest . isCorrect ( ) && northEast . isCorrect ( ) && southWest . isCorrect ( ) && southEast . isCorrect ( ) ; } | Returns whether the tree is consistent or not |
19,546 | public void subDivide ( ) { northWest = new QuadTree ( this , data , new Cell ( boundary . getX ( ) - .5 * boundary . getHw ( ) , boundary . getY ( ) - .5 * boundary . getHh ( ) , .5 * boundary . getHw ( ) , .5 * boundary . getHh ( ) ) ) ; northEast = new QuadTree ( this , data , new Cell ( boundary . getX ( ) + .5 * b... | Create four children which fully divide this cell into four quads of equal area |
19,547 | public int depth ( ) { if ( isLeaf ( ) ) return 1 ; return 1 + max ( max ( northWest . depth ( ) , northEast . depth ( ) ) , max ( southWest . depth ( ) , southEast . depth ( ) ) ) ; } | The depth of the node |
19,548 | public static long [ ] getMaxShape ( INDArray ... inputs ) { if ( inputs == null ) return null ; else if ( inputs . length < 2 ) return inputs [ 0 ] . shape ( ) ; else { long [ ] currMax = inputs [ 0 ] . shape ( ) ; for ( int i = 1 ; i < inputs . length ; i ++ ) { if ( inputs [ i ] == null ) { continue ; } if ( ArrayUt... | Return the shape of the largest length array based on the input |
19,549 | public static boolean isPlaceholderShape ( int [ ] shape ) { if ( shape == null ) return true ; else { for ( int i = 0 ; i < shape . length ; i ++ ) { if ( shape [ i ] < 0 ) return true ; } } return false ; } | Returns true if any shape has a - 1 or a null or empty array is passed in |
19,550 | public static long [ ] getReducedShape ( int [ ] wholeShape , int [ ] dimensions ) { if ( isWholeArray ( wholeShape , dimensions ) ) return new long [ ] { } ; else if ( dimensions . length == 1 && wholeShape . length == 2 ) { val ret = new long [ 2 ] ; if ( dimensions [ 0 ] == 1 ) { ret [ 0 ] = wholeShape [ 0 ] ; ret [... | Get the shape of the reduced array |
19,551 | public static int [ ] getMatrixMultiplyShape ( int [ ] left , int [ ] right ) { if ( Shape . shapeIsScalar ( left ) ) { return right ; } if ( Shape . shapeIsScalar ( right ) ) { return left ; } if ( left . length != 2 && right . length != 2 ) { throw new IllegalArgumentException ( "Illegal shapes for matrix multiply. M... | Get the output shape of a matrix multiply |
19,552 | public static INDArray toOffsetZero ( INDArray arr ) { if ( arr . offset ( ) < 1 && arr . data ( ) . length ( ) == arr . length ( ) ) if ( arr . ordering ( ) == 'f' && arr . stride ( - 1 ) != 1 || arr . ordering ( ) == 'c' && arr . stride ( 0 ) != 1 ) return arr ; if ( arr . isRowVector ( ) ) { INDArray ret = Nd4j . cr... | Create a copy of the matrix where the new offset is zero |
19,553 | public static double getDouble ( INDArray arr , int [ ] indices ) { long offset = getOffset ( arr . shapeInfo ( ) , ArrayUtil . toLongArray ( indices ) ) ; return arr . data ( ) . getDouble ( offset ) ; } | Get a double based on the array and given indices |
19,554 | public static void iterate ( int dimension , int n , int [ ] size , int [ ] res , int dimension2 , int n2 , int [ ] size2 , int [ ] res2 , CoordinateFunction func ) { if ( dimension >= n || dimension2 >= n2 ) { func . process ( ArrayUtil . toLongArray ( res ) , ArrayUtil . toLongArray ( res2 ) ) ; return ; } if ( size2... | Iterate over a pair of coordinates |
19,555 | public static long getOffset ( long baseOffset , int [ ] shape , int [ ] stride , int ... indices ) { if ( shape . length != stride . length || indices . length != shape . length ) throw new IllegalArgumentException ( "Indexes, shape, and stride must be the same length" ) ; long offset = baseOffset ; for ( int i = 0 ; ... | Get an offset for retrieval from a data buffer based on the given shape stride and given indices |
19,556 | public static int [ ] sizeForAxes ( int [ ] axes , int [ ] shape ) { int [ ] ret = new int [ shape . length ] ; for ( int i = 0 ; i < axes . length ; i ++ ) { ret [ i ] = shape [ axes [ i ] ] ; } return ret ; } | Output an int array for a particular dimension |
19,557 | public static boolean shapeEquals ( int [ ] shape1 , int [ ] shape2 ) { if ( isColumnVectorShape ( shape1 ) && isColumnVectorShape ( shape2 ) ) { return Arrays . equals ( shape1 , shape2 ) ; } if ( isRowVectorShape ( shape1 ) && isRowVectorShape ( shape2 ) ) { int [ ] shape1Comp = squeeze ( shape1 ) ; int [ ] shape2Com... | Returns whether 2 shapes are equals by checking for dimension semantics as well as array equality |
19,558 | public static char getOrder ( int [ ] shape , int [ ] stride , int elementStride ) { int sd ; int dim ; int i ; boolean cContiguous = true ; boolean isFortran = true ; sd = 1 ; for ( i = shape . length - 1 ; i >= 0 ; -- i ) { dim = shape [ i ] ; if ( stride [ i ] != sd ) { cContiguous = false ; break ; } if ( dim == 0 ... | Infer order from |
19,559 | public static int [ ] ind2subC ( int [ ] shape , long index , long numIndices ) { long denom = numIndices ; int [ ] ret = new int [ shape . length ] ; for ( int i = 0 ; i < shape . length ; i ++ ) { denom /= shape [ i ] ; if ( index / denom >= Integer . MAX_VALUE ) throw new IllegalArgumentException ( "Dimension can no... | Convert a linear index to the equivalent nd index |
19,560 | public static IntBuffer stride ( IntBuffer buffer ) { int rank = rank ( buffer ) ; val buffer2 = ( Buffer ) buffer ; val ret = ( IntBuffer ) buffer2 . position ( 1 + rank ) ; return ret . slice ( ) ; } | Get the stride for the given shape information buffer |
19,561 | public static String shapeToString ( IntBuffer buffer ) { val shapeBuff = shapeOf ( buffer ) ; int rank = Shape . rank ( buffer ) ; val strideBuff = stride ( buffer ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Rank: " + rank + "," ) ; sb . append ( "Offset: " + Shape . offset ( buffer ) + "\n" ) ; sb .... | Prints the shape for this shape information |
19,562 | public static DataBuffer createShapeInformation ( int [ ] shape , int [ ] stride , long offset , int elementWiseStride , char order ) { if ( shape . length != stride . length ) throw new IllegalStateException ( "Shape and stride must be the same length" ) ; int rank = shape . length ; int shapeBuffer [ ] = new int [ ra... | Creates the shape information buffer given the shape stride |
19,563 | public static IntBuffer toBuffer ( int ... arr ) { ByteBuffer directBuffer = ByteBuffer . allocateDirect ( arr . length * 4 ) . order ( ByteOrder . nativeOrder ( ) ) ; IntBuffer buffer = directBuffer . asIntBuffer ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) buffer . put ( i , arr [ i ] ) ; return buffer ; } | Convert an array to a byte buffer |
19,564 | public static boolean wholeArrayDimension ( int ... arr ) { return arr == null || arr . length == 0 || ( arr . length == 1 && arr [ 0 ] == Integer . MAX_VALUE ) ; } | Returns true if the given array is meant for the whole dimension |
19,565 | public static boolean isContiguousInBuffer ( INDArray in ) { long length = in . length ( ) ; long dLength = in . data ( ) . length ( ) ; if ( length == dLength ) return true ; char order = in . ordering ( ) ; long [ ] shape = in . shape ( ) ; long [ ] stridesIfContiguous ; if ( order == 'f' ) { stridesIfContiguous = Ar... | Are the elements in the buffer contiguous for this NDArray? |
19,566 | public static INDArray toMmulCompatible ( INDArray input ) { if ( input . rank ( ) != 2 ) throw new IllegalArgumentException ( "Input must be rank 2 (matrix)" ) ; boolean doCopy = false ; if ( input . ordering ( ) == 'c' && ( input . stride ( 0 ) != input . size ( 1 ) || input . stride ( 1 ) != 1 ) ) doCopy = true ; el... | This method is used in DL4J LSTM implementation |
19,567 | public static long [ ] reductionShape ( INDArray x , int [ ] dimension , boolean newFormat , boolean keepDims ) { boolean wholeArray = Shape . wholeArrayDimension ( dimension ) || dimension . length == x . rank ( ) ; long [ ] retShape ; if ( ! newFormat ) { retShape = wholeArray ? new long [ ] { 1 , 1 } : ArrayUtil . r... | Calculate the shape of the returned array for a reduction along dimension |
19,568 | public static NavigableMap < String , Integer > loadVocab ( InputStream is ) throws IOException { final TreeMap < String , Integer > map = new TreeMap < > ( Collections . reverseOrder ( ) ) ; try ( final BufferedReader reader = new BufferedReader ( new InputStreamReader ( is ) ) ) { String token ; int i = 0 ; while ( (... | The expected format is a \ n seperated list of tokens for examples |
19,569 | public static Nd4jBackend load ( ) throws NoAvailableBackendException { List < Nd4jBackend > backends = new ArrayList < > ( 1 ) ; ServiceLoader < Nd4jBackend > loader = ServiceLoader . load ( Nd4jBackend . class ) ; try { Iterator < Nd4jBackend > backendIterator = loader . iterator ( ) ; while ( backendIterator . hasNe... | Loads the best available backend . |
19,570 | public static synchronized void loadLibrary ( File jar ) throws NoAvailableBackendException { try { java . net . URLClassLoader loader = ( java . net . URLClassLoader ) ClassLoader . getSystemClassLoader ( ) ; java . net . URL url = jar . toURI ( ) . toURL ( ) ; for ( java . net . URL it : java . util . Arrays . asList... | Adds the supplied Java Archive library to java . class . path . This is benign if the library is already loaded . |
19,571 | public double similarity ( Vertex < V > vertex1 , Vertex < V > vertex2 ) { return similarity ( vertex1 . vertexID ( ) , vertex2 . vertexID ( ) ) ; } | Returns the cosine similarity of the vector representations of two vertices in the graph |
19,572 | public double similarity ( int vertexIdx1 , int vertexIdx2 ) { if ( vertexIdx1 == vertexIdx2 ) return 1.0 ; INDArray vector = Transforms . unitVec ( getVertexVector ( vertexIdx1 ) ) ; INDArray vector2 = Transforms . unitVec ( getVertexVector ( vertexIdx2 ) ) ; return Nd4j . getBlasWrapper ( ) . dot ( vector , vector2 )... | Returns the cosine similarity of the vector representations of two vertices in the graph given the indices of these verticies |
19,573 | private void locate ( double [ ] array , int left , int right , int index ) { int mid = ( left + right ) / 2 ; if ( right == left ) { return ; } if ( left < right ) { double s = array [ mid ] ; int i = left - 1 ; int j = right + 1 ; while ( true ) { while ( array [ ++ i ] < s ) ; while ( array [ -- j ] > s ) ; if ( i >... | sort the partitions by quick sort and locate the target index |
19,574 | public long writeGraphStructure ( SameDiff sd ) throws IOException { Preconditions . checkState ( endStaticInfoOffset < 0 , "Cannot write graph structure - already wrote end of static info marker" ) ; Pair < Integer , FlatBufferBuilder > h = encodeStaticHeader ( UIInfoType . GRAPH_STRUCTURE ) ; FlatBufferBuilder fbb2 =... | Write the graph structure |
19,575 | public long writeFinishStaticMarker ( ) throws IOException { Preconditions . checkState ( endStaticInfoOffset < 0 , "Wrote final static already information already" ) ; Pair < Integer , FlatBufferBuilder > encoded = encodeStaticHeader ( UIInfoType . START_EVENTS ) ; long out = append ( encoded . getSecond ( ) , null ) ... | Write marker for final static data |
19,576 | public StaticInfo readStatic ( ) throws IOException { List < Pair < UIStaticInfoRecord , Table > > out = new ArrayList < > ( ) ; boolean allStaticRead = false ; try ( RandomAccessFile f = new RandomAccessFile ( file , "r" ) ; FileChannel fc = f . getChannel ( ) ) { f . seek ( 0 ) ; while ( ! allStaticRead ) { int lengt... | Read all static information at the start of the file |
19,577 | public List < Pair < UIEvent , Table > > readEvents ( ) throws IOException { Preconditions . checkState ( endStaticInfoOffset >= 0 , "Cannot read events - have not written end of static info marker" ) ; return readEvents ( endStaticInfoOffset ) ; } | Read all of the events . |
19,578 | public List < Pair < UIEvent , Table > > readEvents ( long startOffset ) throws IOException { if ( endStaticInfoOffset >= file . length ( ) ) { return Collections . emptyList ( ) ; } List < Pair < UIEvent , Table > > out = new ArrayList < > ( ) ; try ( RandomAccessFile f = new RandomAccessFile ( file , "r" ) ; FileChan... | Read all of the events starting at a specific file offset |
19,579 | public long registerEventName ( String name ) throws IOException { Preconditions . checkState ( endStaticInfoOffset >= 0 , "Cannot write name - have not written end of static info marker" ) ; FlatBufferBuilder fbb = new FlatBufferBuilder ( 0 ) ; long time = System . currentTimeMillis ( ) ; int offset = UIEvent . create... | Register the event name - accuracy loss etc for later use in recording events . |
19,580 | public long writeScalarEvent ( String name , long time , int iteration , int epoch , Number scalar ) throws IOException { Preconditions . checkState ( indexNameMap . containsKey ( name ) , "Name \"%s\" not yet registered" , name ) ; int idx = indexNameMap . get ( name ) ; FlatBufferBuilder fbb = new FlatBufferBuilder (... | Write a single scalar event to the file |
19,581 | public void initOldStream ( ) { if ( oldStream == null ) { oldStreamFromPool = false ; oldStream = new cudaStream_t ( nativeOps . createStream ( ) ) ; specialStream = new cudaStream_t ( nativeOps . createStream ( ) ) ; } } | Initializes the old stream |
19,582 | public static CudaContext getBlasContext ( ) { CudaContext context = ( CudaContext ) AtomicAllocator . getInstance ( ) . getDeviceContext ( ) . getContext ( ) ; return context ; } | Sets up a context with an old stream and a blas handle |
19,583 | public void receiveUpdate ( INDArray array ) { extCounter . getAndIncrement ( ) ; updatesLock . writeLock ( ) . lock ( ) ; if ( updates == null ) { try ( MemoryWorkspace workspace = Nd4j . getMemoryManager ( ) . scopeOutOfWorkspaces ( ) ) { updates = Nd4j . create ( array . shape ( ) , array . ordering ( ) ) ; } } hasS... | This method accepts updates suitable for StepFunction and puts them to the queue which is used in backpropagation loop |
19,584 | public void defineInputs ( String ... inputNames ) { Preconditions . checkArgument ( inputNames != null && inputNames . length > 0 , "Input names must not be null, and must have length > 0: got %s" , inputNames ) ; this . inputs = Arrays . asList ( inputNames ) ; } | Define the inputs to the DL4J SameDiff Vertex with specific names |
19,585 | public void defineInputs ( int numInputs ) { Preconditions . checkArgument ( numInputs > 0 , "Number of inputs must be > 0: Got %s" , numInputs ) ; String [ ] inputNames = new String [ numInputs ] ; for ( int i = 0 ; i < numInputs ; i ++ ) { inputNames [ i ] = "input_" + i ; } } | Define the inputs to the DL4J SameDiff vertex with generated names . Names will have format input_0 input_1 etc |
19,586 | public static void registerKryoClasses ( SparkConf conf ) { List < Class < ? > > classes = Arrays . < Class < ? > > asList ( BooleanWritable . class , ByteWritable . class , DoubleWritable . class , FloatWritable . class , IntWritable . class , LongWritable . class , NullWritable . class , Text . class ) ; conf . regis... | Register the DataVec writable classes for Kryo |
19,587 | protected void initialize ( ) { log . info ( "Building Huffman tree for source graph..." ) ; int nVertices = sourceGraph . numVertices ( ) ; log . info ( "Transferring Huffman tree info to nodes..." ) ; for ( int i = 0 ; i < nVertices ; i ++ ) { T element = sourceGraph . getVertex ( i ) . getValue ( ) ; element . setEl... | This method handles required initialization for GraphTransformer |
19,588 | public SameDiff importGraph ( GRAPH_TYPE tfGraph ) { return importGraph ( tfGraph , Collections . < String , OpImportOverride < GRAPH_TYPE , NODE_TYPE , ATTR_TYPE > > emptyMap ( ) , null ) ; } | This method converts given TF |
19,589 | public static INDArray buildFromData ( List < DataPoint > data ) { INDArray ret = Nd4j . create ( data . size ( ) , data . get ( 0 ) . getD ( ) ) ; for ( int i = 0 ; i < ret . slices ( ) ; i ++ ) ret . putSlice ( i , data . get ( i ) . getPoint ( ) ) ; return ret ; } | Create an ndarray from the datapoints |
19,590 | public SDVariable max ( String name , SDVariable x , int ... dimensions ) { return max ( name , x , false , dimensions ) ; } | Max array reduction operation optionally along specified dimensions |
19,591 | public SDVariable prod ( String name , SDVariable x , int ... dimensions ) { return prod ( name , x , false , dimensions ) ; } | Product array reduction operation optionally along specified dimensions |
19,592 | public SDVariable scalarSet ( SDVariable in , Number set ) { return scalarSet ( null , in , set ) ; } | Return an array with equal shape to the input but all elements set to value set |
19,593 | public SDVariable scalarSet ( String name , SDVariable in , Number set ) { SDVariable ret = f ( ) . scalarSet ( in , set ) ; return updateVariableNameAndReference ( ret , name ) ; } | Return a variable with equal shape to the input but all elements set to value set |
19,594 | public SDVariable shape ( String name , SDVariable input ) { SDVariable ret = f ( ) . shape ( input ) ; return updateVariableNameAndReference ( ret , name ) ; } | Returns the shape of the specified SDVariable as a 1D SDVariable |
19,595 | public SDVariable standardDeviation ( String name , SDVariable x , boolean biasCorrected , int ... dimensions ) { return standardDeviation ( name , x , biasCorrected , false , dimensions ) ; } | Stardard deviation array reduction operation optionally along specified dimensions |
19,596 | public SDVariable sum ( String name , SDVariable x , int ... dimensions ) { return sum ( name , x , false , dimensions ) ; } | Sum array reduction operation optionally along specified dimensions |
19,597 | public boolean columnCondition ( Writable writable ) { BooleanWritable booleanWritable = ( BooleanWritable ) writable ; return booleanWritable . get ( ) ; } | Returns whether the given element meets the condition set by this operation |
19,598 | public TimingStatistics add ( TimingStatistics timingStatistics ) { return TimingStatistics . builder ( ) . ndarrayCreationTimeNanos ( ndarrayCreationTimeNanos + timingStatistics . ndarrayCreationTimeNanos ) . bandwidthNanosHostToDevice ( bandwidthNanosHostToDevice + timingStatistics . bandwidthNanosHostToDevice ) . di... | Accumulate the given statistics |
19,599 | public static long lengthPerSlice ( INDArray arr , int ... dimension ) { long [ ] remove = ArrayUtil . removeIndex ( arr . shape ( ) , dimension ) ; return ArrayUtil . prodLong ( remove ) ; } | The number of elements in a slice along a set of dimensions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.