idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
19,400 | public INDArray removeEntry ( int idx ) { values = shiftLeft ( values , idx + 1 , 1 , length ( ) ) ; indices = shiftLeft ( indices , ( int ) ( idx * shape . length ( ) + shape . length ( ) ) , ( int ) shape . length ( ) , indices . length ( ) ) ; return this ; } | Remove an element of the ndarray |
19,401 | public int reverseIndexes ( int ... indexes ) { long [ ] idx = translateToPhysical ( ArrayUtil . toLongArray ( indexes ) ) ; sort ( ) ; return indexesBinarySearch ( 0 , ( int ) length ( ) , ArrayUtil . toInts ( idx ) ) ; } | Return the index of the value corresponding to the indexes |
19,402 | public int indexesBinarySearch ( int lowerBound , int upperBound , int [ ] idx ) { int min = lowerBound ; int max = upperBound ; int mid = ( max + min ) / 2 ; int [ ] midIdx = getUnderlyingIndicesOf ( mid ) . asInt ( ) ; if ( Arrays . equals ( idx , midIdx ) ) { return mid ; } if ( ArrayUtil . lessThan ( idx , midIdx )... | Return the position of the idx array into the indexes buffer between the lower and upper bound . |
19,403 | public DataBuffer getVectorCoordinates ( ) { int idx ; if ( isRowVector ( ) ) { idx = 1 ; } else if ( isColumnVector ( ) ) { idx = 0 ; } else { throw new UnsupportedOperationException ( ) ; } int [ ] temp = new int [ ( int ) length ( ) ] ; for ( int i = 0 ; i < length ( ) ; i ++ ) { temp [ i ] = getUnderlyingIndicesOf ... | Returns the indices of non - zero element of the vector |
19,404 | public INDArray toDense ( ) { INDArray result = Nd4j . zeros ( shape ( ) ) ; switch ( data ( ) . dataType ( ) ) { case DOUBLE : for ( int i = 0 ; i < length ; i ++ ) { int [ ] idx = getUnderlyingIndicesOf ( i ) . asInt ( ) ; double value = values . getDouble ( i ) ; result . putScalar ( idx , value ) ; } break ; case F... | Converts the sparse ndarray into a dense one |
19,405 | private long [ ] createSparseOffsets ( long offset ) { int underlyingRank = sparseOffsets ( ) . length ; long [ ] newOffsets = new long [ rank ( ) ] ; List < Long > shapeList = Longs . asList ( shape ( ) ) ; int penultimate = rank ( ) - 1 ; for ( int i = 0 ; i < penultimate ; i ++ ) { long prod = ArrayUtil . prodLong (... | Compute the sparse offsets of the view we are getting for each dimension according to the original ndarray |
19,406 | public DataBuffer getUnderlyingIndicesOf ( int i ) { int from = underlyingRank ( ) * i ; int [ ] res = new int [ underlyingRank ( ) ] ; for ( int j = 0 ; j < underlyingRank ( ) ; j ++ ) { res [ j ] = indices . getInt ( from + j ) ; } return Nd4j . getDataBufferFactory ( ) . createInt ( res ) ; } | Returns the underlying indices of the element of the given index such as there really are in the original ndarray |
19,407 | public DataBuffer getIndicesOf ( int i ) { int from = underlyingRank ( ) * i ; int to = from + underlyingRank ( ) ; int [ ] arr = new int [ rank ] ; int j = 0 ; int k = 0 ; for ( int dim = 0 ; dim < rank ; dim ++ ) { if ( k < hiddenDimensions ( ) . length && hiddenDimensions ( ) [ k ] == j ) { arr [ dim ] = 0 ; k ++ ; ... | Returns the indices of the element of the given index in the array context |
19,408 | public INDArray mmul ( INDArray other , INDArray result , MMulTranspose mMulTranspose ) { return null ; } | Perform an copy matrix multiplication |
19,409 | public static void addNormalizerToModel ( File f , Normalizer < ? > normalizer ) { File tempFile = null ; try { tempFile = DL4JFileUtils . createTempFile ( "dl4jModelSerializerTemp" , "bin" ) ; tempFile . deleteOnExit ( ) ; Files . copy ( f , tempFile ) ; try ( ZipFile zipFile = new ZipFile ( tempFile ) ; ZipOutputStre... | This method appends normalizer to a given persisted model . |
19,410 | public static < T extends Normalizer > T restoreNormalizerFromFile ( File file ) { try ( ZipFile zipFile = new ZipFile ( file ) ) { ZipEntry norm = zipFile . getEntry ( NORMALIZER_BIN ) ; if ( norm == null ) return null ; return NormalizerSerializer . getDefault ( ) . restore ( zipFile . getInputStream ( norm ) ) ; } c... | This method restores normalizer from a given persisted model file |
19,411 | public static < T extends Normalizer > T restoreNormalizerFromInputStream ( InputStream is ) throws IOException { checkInputStream ( is ) ; File tmpFile = null ; try { tmpFile = tempFileFromStream ( is ) ; return restoreNormalizerFromFile ( tmpFile ) ; } finally { if ( tmpFile != null ) { tmpFile . delete ( ) ; } } } | This method restores the normalizer form a persisted model file . |
19,412 | public void load ( File mean , File std ) throws IOException { this . mean = Nd4j . readBinary ( mean ) ; this . std = Nd4j . readBinary ( std ) ; } | Load the given mean and std |
19,413 | public void save ( File mean , File std ) throws IOException { Nd4j . saveBinary ( this . mean , mean ) ; Nd4j . saveBinary ( this . std , std ) ; } | Save the current mean and std |
19,414 | public void transform ( DataSet dataSet ) { dataSet . setFeatures ( dataSet . getFeatures ( ) . subRowVector ( mean ) ) ; dataSet . setFeatures ( dataSet . getFeatures ( ) . divRowVector ( std ) ) ; } | Transform the data |
19,415 | public void readFields ( DataInput in ) throws IOException { DataInputStream dis = new DataInputStream ( new DataInputWrapperStream ( in ) ) ; byte header = dis . readByte ( ) ; if ( header != NDARRAY_SER_VERSION_HEADER && header != NDARRAY_SER_VERSION_HEADER_NULL ) { throw new IllegalStateException ( "Unexpected NDArr... | Deserialize into a row vector of default type . |
19,416 | public void write ( DataOutput out ) throws IOException { if ( array == null ) { out . write ( NDARRAY_SER_VERSION_HEADER_NULL ) ; return ; } INDArray toWrite ; if ( array . isView ( ) ) { toWrite = array . dup ( ) ; } else { toWrite = array ; } out . write ( NDARRAY_SER_VERSION_HEADER ) ; Nd4j . write ( toWrite , new ... | Serialize array data linearly . |
19,417 | public void applyUpdater ( INDArray gradient , int iteration , int epoch ) { if ( v == null ) throw new IllegalStateException ( "Updater has not been initialized with view state" ) ; double momentum = config . currentMomentum ( iteration , epoch ) ; double learningRate = config . getLearningRate ( iteration , epoch ) ;... | Get the nesterov update |
19,418 | public synchronized void shutdown ( ) { if ( stopLock . get ( ) ) return ; transport . shutdown ( ) ; disposable . dispose ( ) ; updaterParamsSubscribers . clear ( ) ; modelParamsSubsribers . clear ( ) ; updatesSubscribers . clear ( ) ; updatesQueue . clear ( ) ; launchLock . set ( false ) ; stopLock . set ( true ) ; } | This method stops parameter server |
19,419 | public Collection < INDArray > getUpdates ( ) { val list = new ArrayList < INDArray > ( ) ; updatesQueue . drainTo ( list ) ; return list ; } | This method returns updates received from network |
19,420 | public ViterbiLattice build ( String text ) { int textLength = text . length ( ) ; ViterbiLattice lattice = new ViterbiLattice ( textLength + 2 ) ; lattice . addBos ( ) ; int unknownWordEndIndex = - 1 ; for ( int startIndex = 0 ; startIndex < textLength ; startIndex ++ ) { if ( lattice . tokenEndsWhereCurrentTokenStart... | Build lattice from input text |
19,421 | private void repairBrokenLatticeBefore ( ViterbiLattice lattice , int index ) { ViterbiNode [ ] [ ] nodeStartIndices = lattice . getStartIndexArr ( ) ; for ( int startIndex = index ; startIndex > 0 ; startIndex -- ) { if ( nodeStartIndices [ startIndex ] != null ) { ViterbiNode glueBase = findGlueNodeCandidate ( index ... | Tries to repair the lattice by creating and adding an additional Viterbi node to the LEFT of the newly inserted user dictionary entry by using the substring of the node in the lattice that overlaps the least |
19,422 | private void repairBrokenLatticeAfter ( ViterbiLattice lattice , int nodeEndIndex ) { ViterbiNode [ ] [ ] nodeEndIndices = lattice . getEndIndexArr ( ) ; for ( int endIndex = nodeEndIndex + 1 ; endIndex < nodeEndIndices . length ; endIndex ++ ) { if ( nodeEndIndices [ endIndex ] != null ) { ViterbiNode glueBase = findG... | Tries to repair the lattice by creating and adding an additional Viterbi node to the RIGHT of the newly inserted user dictionary entry by using the substring of the node in the lattice that overlaps the least |
19,423 | private ViterbiNode findGlueNodeCandidate ( int index , ViterbiNode [ ] latticeNodes , int startIndex ) { List < ViterbiNode > candidates = new ArrayList < > ( ) ; for ( ViterbiNode viterbiNode : latticeNodes ) { if ( viterbiNode != null ) { candidates . add ( viterbiNode ) ; } } if ( ! candidates . isEmpty ( ) ) { Vit... | Tries to locate a candidate for a glue node that repairs the broken lattice by looking at all nodes at the current index . |
19,424 | private boolean isAcceptableCandidate ( int targetLength , ViterbiNode glueBase , ViterbiNode candidate ) { return ( glueBase == null || candidate . getSurface ( ) . length ( ) < glueBase . getSurface ( ) . length ( ) ) && candidate . getSurface ( ) . length ( ) >= targetLength ; } | Check whether a candidate for a glue node is acceptable . The candidate should be as short as possible but long enough to overlap with the inserted user entry |
19,425 | private ViterbiNode createGlueNode ( int startIndex , ViterbiNode glueBase , String surface ) { return new ViterbiNode ( glueBase . getWordId ( ) , surface , glueBase . getLeftId ( ) , glueBase . getRightId ( ) , glueBase . getWordCost ( ) , startIndex , ViterbiNode . Type . INSERTED ) ; } | Create a glue node to be inserted based on ViterbiNode already in the lattice . The new node takes the same parameters as the node it is based on but the word is truncated to match the hole in the lattice caused by the new user entry |
19,426 | public boolean isEmpty ( F element ) { if ( isEmpty ( ) ) return true ; Counter < S > m = maps . get ( element ) ; if ( m == null ) return true ; else return m . isEmpty ( ) ; } | This method checks if this CounterMap has any values stored for a given first element |
19,427 | public void incrementAll ( CounterMap < F , S > other ) { for ( Map . Entry < F , Counter < S > > entry : other . maps . entrySet ( ) ) { F key = entry . getKey ( ) ; Counter < S > innerCounter = entry . getValue ( ) ; for ( Map . Entry < S , AtomicDouble > innerEntry : innerCounter . entrySet ( ) ) { S value = innerEn... | This method will increment values of this counter by counts of other counter |
19,428 | public Pair < F , S > argMax ( ) { Double maxCount = - Double . MAX_VALUE ; Pair < F , S > maxKey = null ; for ( Map . Entry < F , Counter < S > > entry : maps . entrySet ( ) ) { Counter < S > counter = entry . getValue ( ) ; S localMax = counter . argMax ( ) ; if ( counter . getCount ( localMax ) > maxCount || maxKey ... | This method returns pair of elements with a max value |
19,429 | public void clear ( F element ) { Counter < S > s = maps . get ( element ) ; if ( s != null ) s . clear ( ) ; } | This method purges counter for a given first element |
19,430 | public int totalSize ( ) { int size = 0 ; for ( F first : keySet ( ) ) { size += getCounter ( first ) . size ( ) ; } return size ; } | This method returns total number of elements in this CounterMap |
19,431 | public void tpsv ( char order , char Uplo , char TransA , char Diag , INDArray Ap , INDArray X ) { if ( Nd4j . getExecutioner ( ) . getProfilingMode ( ) == OpExecutioner . ProfilingMode . ALL ) OpProfiler . getInstance ( ) . processBlasCall ( false , Ap , X ) ; if ( X . data ( ) . dataType ( ) == DataType . DOUBLE ) { ... | tpsv solves a system of linear equations whose coefficients are in a triangular packed matrix . |
19,432 | public static FingerprintProperties getInstance ( ) { if ( instance == null ) { synchronized ( FingerprintProperties . class ) { if ( instance == null ) { instance = new FingerprintProperties ( ) ; } } } return instance ; } | num frequency units |
19,433 | private Result listSessions ( ) { StringBuilder sb = new StringBuilder ( "<!DOCTYPE html>\n" + "<html lang=\"en\">\n" + "<head>\n" + " <meta charset=\"utf-8\">\n" + " <title>Training sessions - DL4J Training UI</title>\n" + " </head>\n" + "\n" + " <body>\n" + " <h1>DL4J Training UI</h1>\n" + ... | List training sessions |
19,434 | private Result sessionNotFound ( String sessionId , String targetPath ) { if ( sessionLoader != null && sessionLoader . apply ( sessionId ) ) { if ( targetPath != null ) { return temporaryRedirect ( "./" + targetPath ) ; } else { return ok ( ) ; } } else { return notFound ( "Unknown session ID: " + sessionId ) ; } } | Load StatsStorage via provider or return not found |
19,435 | private Long getLastUpdateTime ( String sessionId ) { if ( lastUpdateForSession != null && sessionId != null && lastUpdateForSession . containsKey ( sessionId ) ) { return lastUpdateForSession . get ( sessionId ) ; } else { return - 1L ; } } | Get last update time for given session ID checking for null values |
19,436 | public void publish ( NDArrayMessage message ) throws Exception { if ( ! init ) init ( ) ; boolean connected = false ; if ( aeron == null ) { try { while ( ! connected ) { aeron = Aeron . connect ( ctx ) ; connected = true ; } } catch ( Exception e ) { log . warn ( "Reconnecting on publisher...failed to connect" ) ; } ... | Publish an ndarray to an aeron channel |
19,437 | public CoOccurrenceWeight < T > nextObject ( ) { String line = iterator . nextSentence ( ) ; if ( line == null || line . isEmpty ( ) ) { return null ; } String [ ] strings = line . split ( " " ) ; CoOccurrenceWeight < T > object = new CoOccurrenceWeight < > ( ) ; object . setElement1 ( vocabCache . elementAtIndex ( Int... | Returns next CoOccurrenceWeight object |
19,438 | public static ComputationGraphConfiguration fromJson ( String json ) { ObjectMapper mapper = NeuralNetConfiguration . mapper ( ) ; ComputationGraphConfiguration conf ; try { conf = mapper . readValue ( json , ComputationGraphConfiguration . class ) ; } catch ( Exception e ) { String msg = e . getMessage ( ) ; if ( msg ... | Create a computation graph configuration from json |
19,439 | public void validate ( boolean allowDisconnected , boolean allowNoOutput ) { if ( networkInputs == null || networkInputs . isEmpty ( ) ) { throw new IllegalStateException ( "Invalid configuration: network has no inputs. " + "Use .addInputs(String...) to label (and give an ordering to) the network inputs" ) ; } if ( ( n... | Check the configuration make sure it is valid |
19,440 | public void load ( File ... statistics ) throws IOException { setFeatureStats ( new MinMaxStats ( Nd4j . readBinary ( statistics [ 0 ] ) , Nd4j . readBinary ( statistics [ 1 ] ) ) ) ; if ( isFitLabel ( ) ) { setLabelStats ( new MinMaxStats ( Nd4j . readBinary ( statistics [ 2 ] ) , Nd4j . readBinary ( statistics [ 3 ] ... | Load the given min and max |
19,441 | public void save ( File ... files ) throws IOException { Nd4j . saveBinary ( getMin ( ) , files [ 0 ] ) ; Nd4j . saveBinary ( getMax ( ) , files [ 1 ] ) ; if ( isFitLabel ( ) ) { Nd4j . saveBinary ( getLabelMin ( ) , files [ 2 ] ) ; Nd4j . saveBinary ( getLabelMax ( ) , files [ 3 ] ) ; } } | Save the current min and max |
19,442 | public static String versionInfoString ( Detail detail ) { StringBuilder sb = new StringBuilder ( ) ; for ( VersionInfo grp : getVersionInfos ( ) ) { sb . append ( grp . getGroupId ( ) ) . append ( " : " ) . append ( grp . getArtifactId ( ) ) . append ( " : " ) . append ( grp . getBuildVersion ( ) ) ; switch ( detail )... | Get the version information for dependencies as a string with a specified amount of detail |
19,443 | public static void logVersionInfo ( Detail detail ) { List < VersionInfo > info = getVersionInfos ( ) ; for ( VersionInfo grp : info ) { switch ( detail ) { case GAV : log . info ( "{} : {} : {}" , grp . getGroupId ( ) , grp . getArtifactId ( ) , grp . getBuildVersion ( ) ) ; break ; case GAVC : log . info ( "{} : {} :... | Log the version information with the specified level of detail |
19,444 | public INDArray getConvParameterValues ( INDArray kerasParamValue ) throws InvalidKerasConfigurationException { INDArray paramValue ; switch ( this . getDimOrder ( ) ) { case TENSORFLOW : if ( kerasParamValue . rank ( ) == 5 ) paramValue = kerasParamValue . permute ( 4 , 3 , 0 , 1 , 2 ) ; else paramValue = kerasParamVa... | Return processed parameter values obtained from Keras convolutional layers . |
19,445 | public Vendor getBlasVendor ( ) { int vendor = getBlasVendorId ( ) ; boolean isUnknowVendor = ( ( vendor > Vendor . values ( ) . length - 1 ) || ( vendor <= 0 ) ) ; if ( isUnknowVendor ) { return Vendor . UNKNOWN ; } return Vendor . values ( ) [ vendor ] ; } | Returns the BLAS library vendor |
19,446 | public void setIfUnset ( String name , String value ) { if ( get ( name ) == null ) { set ( name , value ) ; } } | Sets a property if it is currently unset . |
19,447 | public boolean hasNext ( ) { if ( next != null ) { return true ; } if ( ! recordReader . hasNext ( ) ) { return false ; } while ( next == null && recordReader . hasNext ( ) ) { Record r = recordReader . nextRecord ( ) ; List < Writable > temp = transformProcess . execute ( r . getRecord ( ) ) ; if ( temp == null ) { co... | Whether there are anymore records |
19,448 | public static ClusterSetInfo classifyPoints ( final ClusterSet clusterSet , List < Point > points , ExecutorService executorService ) { final ClusterSetInfo clusterSetInfo = ClusterSetInfo . initialize ( clusterSet , true ) ; List < Runnable > tasks = new ArrayList < > ( ) ; for ( final Point point : points ) { try { P... | Classify the set of points base on cluster centers . This also adds each point to the ClusterSet |
19,449 | public Blob convert ( INDArray toConvert ) throws SQLException { ByteBuffer byteBuffer = BinarySerde . toByteBuffer ( toConvert ) ; Buffer buffer = ( Buffer ) byteBuffer ; buffer . rewind ( ) ; byte [ ] arr = new byte [ byteBuffer . capacity ( ) ] ; byteBuffer . get ( arr ) ; Connection c = dataSource . getConnection (... | Convert an ndarray to a blob |
19,450 | public INDArray load ( Blob blob ) throws SQLException { if ( blob == null ) return null ; try ( InputStream is = blob . getBinaryStream ( ) ) { ByteBuffer direct = ByteBuffer . allocateDirect ( ( int ) blob . length ( ) ) ; ReadableByteChannel readableByteChannel = Channels . newChannel ( is ) ; readableByteChannel . ... | Load an ndarray from a blob |
19,451 | public void save ( INDArray save , String id ) throws SQLException , IOException { doSave ( save , id ) ; } | Save the ndarray |
19,452 | public Blob loadForID ( String id ) throws SQLException { Connection c = dataSource . getConnection ( ) ; PreparedStatement preparedStatement = c . prepareStatement ( loadStatement ( ) ) ; preparedStatement . setString ( 1 , id ) ; ResultSet r = preparedStatement . executeQuery ( ) ; if ( r . wasNull ( ) || ! r . next ... | Load an ndarray blob given an id |
19,453 | public void delete ( String id ) throws SQLException { Connection c = dataSource . getConnection ( ) ; PreparedStatement p = c . prepareStatement ( deleteStatement ( ) ) ; p . setString ( 1 , id ) ; p . execute ( ) ; } | Delete the given ndarray |
19,454 | private int getInputDimFromConfig ( Map < String , Object > layerConfig ) throws InvalidKerasConfigurationException { Map < String , Object > innerConfig = KerasLayerUtils . getInnerLayerConfigFromConfig ( layerConfig , conf ) ; if ( ! innerConfig . containsKey ( conf . getLAYER_FIELD_INPUT_DIM ( ) ) ) throw new Invali... | Get Keras input dimension from Keras layer configuration . |
19,455 | @ SuppressWarnings ( "unchecked" ) public void processMessage ( ) { TrainingDriver < SkipGramRequestMessage > sgt = ( TrainingDriver < SkipGramRequestMessage > ) trainer ; sgt . startTraining ( this ) ; } | This method does actual training for SkipGram algorithm |
19,456 | public static void writeParagraphVectors ( ParagraphVectors vectors , File file ) { try ( FileOutputStream fos = new FileOutputStream ( file ) ; BufferedOutputStream stream = new BufferedOutputStream ( fos ) ) { writeParagraphVectors ( vectors , stream ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } ... | This method saves ParagraphVectors model into compressed zip file |
19,457 | public static void writeWordVectors ( ParagraphVectors vectors , OutputStream stream ) { try ( BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( stream , StandardCharsets . UTF_8 ) ) ) { VocabCache < VocabWord > vocabCache = vectors . getVocab ( ) ; for ( VocabWord word : vocabCache . vocabWords ( )... | This method saves paragraph vectors to the given output stream . |
19,458 | public static WordVectors fromTableAndVocab ( WeightLookupTable table , VocabCache vocab ) { WordVectorsImpl vectors = new WordVectorsImpl ( ) ; vectors . setLookupTable ( table ) ; vectors . setVocab ( vocab ) ; vectors . setModelUtils ( new BasicModelUtils ( ) ) ; return vectors ; } | Load word vectors for the given vocab and table |
19,459 | public static Word2Vec fromPair ( Pair < InMemoryLookupTable , VocabCache > pair ) { Word2Vec vectors = new Word2Vec ( ) ; vectors . setLookupTable ( pair . getFirst ( ) ) ; vectors . setVocab ( pair . getSecond ( ) ) ; vectors . setModelUtils ( new BasicModelUtils ( ) ) ; return vectors ; } | Load word vectors from the given pair |
19,460 | public static void writeTsneFormat ( Glove vec , INDArray tsne , File csv ) throws Exception { try ( BufferedWriter write = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( csv ) , StandardCharsets . UTF_8 ) ) ) { int words = 0 ; InMemoryLookupCache l = ( InMemoryLookupCache ) vec . vocab ( ) ; for ... | Write the tsne format |
19,461 | public INDArray outputFromFeaturized ( INDArray input ) { if ( isGraph ) { if ( unFrozenSubsetGraph . getNumOutputArrays ( ) > 1 ) { throw new IllegalArgumentException ( "Graph has more than one output. Expecting an input array with outputFromFeaturized method call" ) ; } return unFrozenSubsetGraph . output ( input ) [... | Use to get the output from a featurized input |
19,462 | public static Evaluation getEvaluation ( ComputationGraph model , MultiDataSetIterator testData ) { if ( model . getNumOutputArrays ( ) != 1 ) throw new IllegalStateException ( "GraphSetSetAccuracyScoreFunction cannot be " + "applied to ComputationGraphs with more than one output. NumOutputs = " + model . getNumOutputA... | Get the evaluation for the given model and test dataset |
19,463 | public static double score ( ComputationGraph model , MultiDataSetIterator testData , boolean average ) { double sumScore = 0.0 ; int totalExamples = 0 ; while ( testData . hasNext ( ) ) { MultiDataSet ds = testData . next ( ) ; long numExamples = ds . getFeatures ( 0 ) . size ( 0 ) ; sumScore += numExamples * model . ... | Score based on the loss function |
19,464 | public static double score ( MultiLayerNetwork model , DataSetIterator testData , boolean average ) { double sumScore = 0.0 ; int totalExamples = 0 ; while ( testData . hasNext ( ) ) { DataSet ds = testData . next ( ) ; int numExamples = ds . numExamples ( ) ; sumScore += numExamples * model . score ( ds ) ; totalExamp... | Score the given test data with the given multi layer network |
19,465 | public static double score ( MultiLayerNetwork model , DataSetIterator testSet , RegressionValue regressionValue ) { RegressionEvaluation eval = model . evaluateRegression ( testSet ) ; return getScoreFromRegressionEval ( eval , regressionValue ) ; } | Score the given multi layer network |
19,466 | public String getMatchingAddress ( ) { if ( informationCollection . size ( ) > 1 ) this . informationCollection = buildLocalInformation ( ) ; List < String > list = getSubset ( 1 ) ; if ( list . size ( ) < 1 ) throw new ND4JIllegalStateException ( "Unable to find network interface matching requested mask: " + networkMa... | This method returns local IP address that matches given network mask . To be used with single - argument constructor only . |
19,467 | public List < String > getSubset ( int numShards , Collection < String > primary ) { if ( networkMask == null ) return getIntersections ( numShards , primary ) ; List < String > addresses = new ArrayList < > ( ) ; SubnetUtils utils = new SubnetUtils ( networkMask ) ; Collections . shuffle ( informationCollection ) ; fo... | This method returns specified number of IP addresses from original list of addresses that are NOT listen in primary collection |
19,468 | private void processReturnedTask ( Future < OptimizationResult > future ) { long currentTime = System . currentTimeMillis ( ) ; OptimizationResult result ; try { result = future . get ( 100 , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( "Unexpected InterruptedException t... | Process returned task ( either completed or failed |
19,469 | protected void set ( final int n , final Rational value ) { final int nindx = n / 2 ; if ( nindx < a . size ( ) ) { a . set ( nindx , value ) ; } else { while ( a . size ( ) < nindx ) { a . add ( Rational . ZERO ) ; } a . add ( value ) ; } } | Set a coefficient in the internal table . |
19,470 | public Rational at ( int n ) { if ( n == 1 ) { return ( new Rational ( - 1 , 2 ) ) ; } else if ( n % 2 != 0 ) { return Rational . ZERO ; } else { final int nindx = n / 2 ; if ( a . size ( ) <= nindx ) { for ( int i = 2 * a . size ( ) ; i <= n ; i += 2 ) { set ( i , doubleSum ( i ) ) ; } } return a . get ( nindx ) ; } } | The Bernoulli number at the index provided . |
19,471 | public static SequenceBatchCSVRecord fromWritables ( List < List < List < Writable > > > input ) { SequenceBatchCSVRecord ret = new SequenceBatchCSVRecord ( ) ; for ( int i = 0 ; i < input . size ( ) ; i ++ ) { ret . add ( Arrays . asList ( BatchCSVRecord . fromWritables ( input . get ( i ) ) ) ) ; } return ret ; } | Convert a writables time series to a sequence batch |
19,472 | public BufferedImage asBufferedImage ( INDArray array , int dataType ) { return converter2 . convert ( asFrame ( array , dataType ) ) ; } | Converts an INDArray to a BufferedImage . Only intended for images with rank 3 . |
19,473 | public Deque < Integer > getCrossoverPoints ( ) { Collections . shuffle ( parameterIndexes ) ; List < Integer > crossoverPointLists = parameterIndexes . subList ( 0 , rng . nextInt ( maxCrossovers - minCrossovers ) + minCrossovers ) ; Collections . sort ( crossoverPointLists ) ; Deque < Integer > crossoverPoints = new ... | Generate a list of crossover points . |
19,474 | public double tfidfWord ( String word , long wordCount , long documentLength ) { double tf = tfForWord ( wordCount , documentLength ) ; double idf = idfForWord ( word ) ; return MathUtils . tfidf ( tf , idf ) ; } | Calculate the tifdf for a word given the word word count and document length |
19,475 | public static void registerCustomLayer ( String layerName , Class < ? extends KerasLayer > configClass ) { customLayers . put ( layerName , configClass ) ; } | Register a custom layer |
19,476 | public void copyWeightsToLayer ( org . deeplearning4j . nn . api . Layer layer ) throws InvalidKerasConfigurationException { if ( this . getNumParams ( ) > 0 ) { String dl4jLayerName = layer . conf ( ) . getLayer ( ) . getLayerName ( ) ; String kerasLayerName = this . getLayerName ( ) ; String msg = "Error when attempt... | Copy Keras layer weights to DL4J Layer . |
19,477 | protected long getNInFromConfig ( Map < String , ? extends KerasLayer > previousLayers ) throws UnsupportedKerasConfigurationException { int size = previousLayers . size ( ) ; int count = 0 ; long nIn ; String inboundLayerName = inboundLayerNames . get ( 0 ) ; while ( count <= size ) { if ( previousLayers . containsKey... | Some DL4J layers need explicit specification of number of inputs which Keras does infer . This method searches through previous layers until a FeedForwardLayer is found . These layers have nOut values that subsequently correspond to the nIn value of this layer . |
19,478 | public SDVariable layerNorm ( SDVariable input , SDVariable gain , int ... dimensions ) { return layerNorm ( ( String ) null , input , gain , dimensions ) ; } | Apply Layer Normalization without bias |
19,479 | public void setConf ( Configuration conf ) { super . setConf ( conf ) ; featureFirstColumn = conf . getInt ( FEATURE_FIRST_COLUMN , 0 ) ; hasLabel = conf . getBoolean ( HAS_LABELS , true ) ; multilabel = conf . getBoolean ( MULTILABEL , false ) ; labelFirstColumn = conf . getInt ( LABEL_FIRST_COLUMN , - 1 ) ; labelLast... | Set DataVec configuration |
19,480 | public boolean updaterDivideByMinibatch ( String paramName ) { int idx = paramName . indexOf ( '_' ) ; int layerIdx = Integer . parseInt ( paramName . substring ( 0 , idx ) ) ; String subName = paramName . substring ( idx + 1 ) ; return getLayer ( layerIdx ) . updaterDivideByMinibatch ( subName ) ; } | Intended for internal use |
19,481 | public INDArray activateSelectedLayers ( int from , int to , INDArray input ) { if ( input == null ) throw new IllegalStateException ( "Unable to perform activation; no input found" ) ; if ( from < 0 || from >= layers . length || from >= to ) throw new IllegalStateException ( "Unable to perform activation; FROM is out ... | Calculate activation for few layers at once . Suitable for autoencoder partial activation . |
19,482 | public long numParams ( boolean backwards ) { int length = 0 ; for ( int i = 0 ; i < layers . length ; i ++ ) length += layers [ i ] . numParams ( backwards ) ; return length ; } | Returns the number of parameters in the network |
19,483 | public double f1Score ( org . nd4j . linalg . dataset . api . DataSet data ) { return f1Score ( data . getFeatures ( ) , data . getLabels ( ) ) ; } | Sets the input and labels and returns the F1 score for the prediction with respect to the true labels |
19,484 | public void clear ( ) { for ( Layer layer : layers ) layer . clear ( ) ; input = null ; labels = null ; solver = null ; } | Clear the inputs . Clears optimizer state . |
19,485 | public void setInput ( INDArray input ) { this . input = input ; if ( this . layers == null ) { init ( ) ; } if ( input != null ) { if ( input . length ( ) == 0 ) throw new IllegalArgumentException ( "Invalid input: length 0 (shape: " + Arrays . toString ( input . shape ( ) ) + ")" ) ; setInputMiniBatchSize ( ( int ) i... | Set the input array for the network |
19,486 | public Layer getOutputLayer ( ) { Layer ret = getLayers ( ) [ getLayers ( ) . length - 1 ] ; if ( ret instanceof FrozenLayerWithBackprop ) { ret = ( ( FrozenLayerWithBackprop ) ret ) . getInsideLayer ( ) ; } return ret ; } | Get the output layer - i . e . the last layer in the netwok |
19,487 | public < T extends RegressionEvaluation > T evaluateRegression ( DataSetIterator iterator ) { return ( T ) doEvaluation ( iterator , new RegressionEvaluation ( iterator . totalOutcomes ( ) ) ) [ 0 ] ; } | Evaluate the network for regression performance |
19,488 | public static int createDims ( FlatBufferBuilder bufferBuilder , INDArray arr ) { int [ ] tensorDimOffsets = new int [ arr . rank ( ) ] ; int [ ] nameOffset = new int [ arr . rank ( ) ] ; for ( int i = 0 ; i < tensorDimOffsets . length ; i ++ ) { nameOffset [ i ] = bufferBuilder . createString ( "" ) ; tensorDimOffsets... | Create the dimensions for the flatbuffer builder |
19,489 | public Bitmap asBitmap ( INDArray array , int dataType ) { return converter2 . convert ( asFrame ( array , dataType ) ) ; } | Converts an INDArray to a Bitmap . Only intended for images with rank 3 . |
19,490 | public int totalCount ( int outputNum ) { assertIndex ( outputNum ) ; return countTruePositive [ outputNum ] + countTrueNegative [ outputNum ] + countFalseNegative [ outputNum ] + countFalsePositive [ outputNum ] ; } | Get the total number of values for the specified column accounting for any masking |
19,491 | public double accuracy ( int outputNum ) { assertIndex ( outputNum ) ; return ( countTruePositive [ outputNum ] + countTrueNegative [ outputNum ] ) / ( double ) totalCount ( outputNum ) ; } | Get the accuracy for the specified output |
19,492 | public double fBeta ( double beta , int outputNum ) { assertIndex ( outputNum ) ; double precision = precision ( outputNum ) ; double recall = recall ( outputNum ) ; return EvaluationUtils . fBeta ( beta , precision , recall ) ; } | Calculate the F - beta value for the given output |
19,493 | public double matthewsCorrelation ( int outputNum ) { assertIndex ( outputNum ) ; return EvaluationUtils . matthewsCorrelation ( truePositives ( outputNum ) , falsePositives ( outputNum ) , falseNegatives ( outputNum ) , trueNegatives ( outputNum ) ) ; } | Calculate the Matthews correlation coefficient for the specified output |
19,494 | public double gMeasure ( int output ) { double precision = precision ( output ) ; double recall = recall ( output ) ; return EvaluationUtils . gMeasure ( precision , recall ) ; } | Calculate the G - measure for the given output |
19,495 | public double falseNegativeRate ( Integer classLabel , double edgeCase ) { double fnCount = falseNegatives ( classLabel ) ; double tpCount = truePositives ( classLabel ) ; return EvaluationUtils . falseNegativeRate ( ( long ) fnCount , ( long ) tpCount , edgeCase ) ; } | Returns the false negative rate for a given label |
19,496 | public String stats ( int printPrecision ) { StringBuilder sb = new StringBuilder ( ) ; int maxLabelsLength = 15 ; if ( labels != null ) { for ( String s : labels ) { maxLabelsLength = Math . max ( s . length ( ) , maxLabelsLength ) ; } } String subPattern = "%-12." + printPrecision + "f" ; String pattern = "%-" + ( ma... | Get a String representation of the EvaluationBinary class using the specified precision |
19,497 | public FingerprintSimilarity getFingerprintsSimilarity ( ) { HashMap < Integer , Integer > offset_Score_Table = new HashMap < > ( ) ; int numFrames ; float score = 0 ; int mostSimilarFramePosition = Integer . MIN_VALUE ; if ( fingerprint1 . length > fingerprint2 . length ) { numFrames = FingerprintManager . getNumFrame... | Get fingerprint similarity of inout fingerprints |
19,498 | public static List < SubGraph > getSubgraphsMatching ( SameDiff sd , SubGraphPredicate p ) { List < SubGraph > out = new ArrayList < > ( ) ; for ( DifferentialFunction df : sd . functions ( ) ) { if ( p . matches ( sd , df ) ) { SubGraph sg = p . getSubGraph ( sd , df ) ; out . add ( sg ) ; } } return out ; } | Get a list of all the subgraphs that match the specified predicate |
19,499 | public String confusionMatrix ( ) { int nClasses = numClasses ( ) ; if ( confusion == null ) { return "Confusion matrix: <no data>" ; } List < Integer > classes = confusion . getClasses ( ) ; int maxCount = 1 ; for ( Integer i : classes ) { for ( Integer j : classes ) { int count = confusion ( ) . getCount ( i , j ) ; ... | Get the confusion matrix as a String |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.