Java Code Examples for org.datavec.api.conf.Configuration#getBoolean()

The following examples show how to use org.datavec.api.conf.Configuration#getBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseImageRecordReader.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.appendLabel = conf.getBoolean(APPEND_LABEL, appendLabel);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    this.height = conf.getInt(HEIGHT, height);
    this.width = conf.getInt(WIDTH, width);
    this.channels = conf.getInt(CHANNELS, channels);
    this.cropImage = conf.getBoolean(CROP_IMAGE, cropImage);
    if ("imageio".equals(conf.get(IMAGE_LOADER))) {
        this.imageLoader = new ImageLoader(height, width, channels, cropImage);
    } else {
        this.imageLoader = new NativeImageLoader(height, width, channels, imageTransform);
    }
    this.conf = conf;
    initialize(split);
}
 
Example 2
Source File: SVMLightRecordReader.java    From DataVec with Apache License 2.0 6 votes vote down vote up
/**
 * Set configuration.
 *
 * @param conf          DataVec configuration
 * @throws IOException
 * @throws InterruptedException
 */
@Override
public void setConf(Configuration conf) {
    super.setConf(conf);
    numFeatures = conf.getInt(NUM_FEATURES, -1);
    if (numFeatures < 0)
        numFeatures = conf.getInt(NUM_ATTRIBUTES, -1);
    if (numFeatures < 0)
        throw new UnsupportedOperationException("numFeatures must be set in configuration");
    appendLabel = conf.getBoolean(APPEND_LABEL, true);
    multilabel = conf.getBoolean(MULTILABEL, false);
    zeroBasedIndexing = conf.getBoolean(ZERO_BASED_INDEXING, true);
    zeroBasedLabelIndexing = conf.getBoolean(ZERO_BASED_LABEL_INDEXING, false);
    numLabels = conf.getInt(NUM_LABELS, -1);
    if (multilabel && numLabels < 0)
        throw new UnsupportedOperationException("numLabels must be set in confirmation for multilabel problems");
}
 
Example 3
Source File: BaseImageRecordReader.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.appendLabel = conf.getBoolean(APPEND_LABEL, appendLabel);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    this.height = conf.getLong(HEIGHT, height);
    this.width = conf.getLong(WIDTH, width);
    this.channels = conf.getLong(CHANNELS, channels);
    this.cropImage = conf.getBoolean(CROP_IMAGE, cropImage);
    if ("imageio".equals(conf.get(IMAGE_LOADER))) {
        this.imageLoader = new ImageLoader(height, width, channels, cropImage);
    } else {
        this.imageLoader = new NativeImageLoader(height, width, channels, imageTransform);
    }
    this.conf = conf;
    initialize(split);
}
 
Example 4
Source File: SVMLightRecordReader.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
/**
 * Set configuration.
 *
 * @param conf          DataVec configuration
 * @throws IOException
 * @throws InterruptedException
 */
@Override
public void setConf(Configuration conf) {
    super.setConf(conf);
    numFeatures = conf.getInt(NUM_FEATURES, -1);
    if (numFeatures < 0)
        numFeatures = conf.getInt(NUM_ATTRIBUTES, -1);
    if (numFeatures < 0)
        throw new UnsupportedOperationException("numFeatures must be set in configuration");
    appendLabel = conf.getBoolean(APPEND_LABEL, true);
    multilabel = conf.getBoolean(MULTILABEL, false);
    zeroBasedIndexing = conf.getBoolean(ZERO_BASED_INDEXING, true);
    zeroBasedLabelIndexing = conf.getBoolean(ZERO_BASED_LABEL_INDEXING, false);
    numLabels = conf.getInt(NUM_LABELS, -1);
    if (multilabel && numLabels < 0)
        throw new UnsupportedOperationException("numLabels must be set in confirmation for multilabel problems");
}
 
Example 5
Source File: VasttextTextVectorizer.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf) {

	tokenizerFactory = new DefaultTokenizerFactory();
       minWordFrequency = conf.getInt(MIN_WORD_FREQUENCY, 5);
       maxNgrams = conf.getInt(NGRAMS, 1);
       maxSkipBigrams = conf.getInt(SKIP_NGRAMS, 0);

       if(conf.getBoolean(DELETE_STOP_WORDS, false))
       {
       	System.err.println("StopWord Removal: Yes");
        stopWords = conf.getStringCollection(STOP_WORDS);
        if (stopWords == null || stopWords.isEmpty())
            stopWords = StopWords.getStopWords();
       }
       else
       	System.err.println("StopWord Removal: No");
       System.err.println("Freq min:"+minWordFrequency);
       
       System.err.println("N-grams:"+maxNgrams);
       
       System.err.println("Skip bigrams:"+maxSkipBigrams);
       
	cache = new VasttextDictionary();
       cache.initialize(conf);
	cache.setMaxNgrams(maxNgrams);
	cache.setMaxSkipBigrams(maxSkipBigrams);
}
 
Example 6
Source File: VideoRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.conf = conf;
    this.appendLabel = conf.getBoolean(APPEND_LABEL, false);
    this.height = conf.getInt(HEIGHT, height);
    this.width = conf.getInt(WIDTH, width);
    if ("imageio".equals(conf.get(IMAGE_LOADER))) {
        this.imageLoader = new ImageLoader(height, width);
    } else {
        this.imageLoader = new NativeImageLoader(height, width);
    }

    initialize(split);
}
 
Example 7
Source File: BaseAudioRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.conf = conf;
    this.appendLabel = conf.getBoolean(APPEND_LABEL, false);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    initialize(split);
}
 
Example 8
Source File: BaseCodecRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void setConf(Configuration conf) {
    super.setConf(conf);
    startFrame = conf.getInt(START_FRAME, 0);
    numFrames = conf.getInt(TOTAL_FRAMES, -1);
    rows = conf.getInt(ROWS, 28);
    cols = conf.getInt(COLUMNS, 28);
    framesPerSecond = conf.getFloat(TIME_SLICE, -1);
    videoLength = conf.getFloat(VIDEO_DURATION, -1);
    ravel = conf.getBoolean(RAVEL, false);
    totalFrames = conf.getInt(TOTAL_FRAMES, -1);
}
 
Example 9
Source File: SVMLightRecordWriter.java    From DataVec with Apache License 2.0 5 votes vote down vote up
/**
 * Set DataVec configuration
 *
 * @param conf
 */
@Override
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);
    labelLastColumn = conf.getInt(LABEL_LAST_COLUMN, -1);
    featureLastColumn = conf.getInt(FEATURE_LAST_COLUMN, labelFirstColumn > 0 ? labelFirstColumn-1 : -1);
    zeroBasedIndexing = conf.getBoolean(ZERO_BASED_INDEXING, false);
    zeroBasedLabelIndexing = conf.getBoolean(ZERO_BASED_LABEL_INDEXING, false);
}
 
Example 10
Source File: FileRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    appendLabel = conf.getBoolean(APPEND_LABEL, true);
    doInitialize(split);
    this.inputSplit = split;
    this.conf = conf;
}
 
Example 11
Source File: BaseAudioRecordReader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.conf = conf;
    this.appendLabel = conf.getBoolean(APPEND_LABEL, false);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    initialize(split);
}
 
Example 12
Source File: BaseCodecRecordReader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void setConf(Configuration conf) {
    super.setConf(conf);
    startFrame = conf.getInt(START_FRAME, 0);
    numFrames = conf.getInt(TOTAL_FRAMES, -1);
    rows = conf.getInt(ROWS, 28);
    cols = conf.getInt(COLUMNS, 28);
    framesPerSecond = conf.getFloat(TIME_SLICE, -1);
    videoLength = conf.getFloat(VIDEO_DURATION, -1);
    ravel = conf.getBoolean(RAVEL, false);
    totalFrames = conf.getInt(TOTAL_FRAMES, -1);
}
 
Example 13
Source File: SVMLightRecordWriter.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * Set DataVec configuration
 *
 * @param conf
 */
@Override
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);
    labelLastColumn = conf.getInt(LABEL_LAST_COLUMN, -1);
    featureLastColumn = conf.getInt(FEATURE_LAST_COLUMN, labelFirstColumn > 0 ? labelFirstColumn-1 : -1);
    zeroBasedIndexing = conf.getBoolean(ZERO_BASED_INDEXING, false);
    zeroBasedLabelIndexing = conf.getBoolean(ZERO_BASED_LABEL_INDEXING, false);
}
 
Example 14
Source File: FileRecordReader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    appendLabel = conf.getBoolean(APPEND_LABEL, true);
    doInitialize(split);
    this.inputSplit = split;
    this.conf = conf;
}
 
Example 15
Source File: VasttextTextFileReader.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    super.initialize(conf, split);
    multilabel = conf.getBoolean(MULTILABEL, false);
    labelled = conf.getBoolean(LABELLED, false);
    //train  a new one since it hasn't been specified
    if (vasttextTextVectorizer == null) {
        vasttextTextVectorizer = new VasttextTextVectorizer();
        vasttextTextVectorizer.initialize(conf);
        //clear out old strings
        records.clear();

        vasttextTextVectorizer.fitTransform(this, new Vectorizer.RecordCallBack() {
            @Override
            public void onRecord(Record fullRecord) {
                records.add(fullRecord);
            }
        });

        //cache the number of features used for each document
        textFeaturesSize = vasttextTextVectorizer.getVocabularySize();
        recordIter = records.iterator();
        vasttextTextVectorizer.setfitFinished();
    } else {
        records = new ArrayList<>();
        int lastLine=0;
        //the record reader has 2 phases, we are skipping the
        //document frequency phase and just using the super() to get the file contents
        //and pass it to the already existing vectorizer.
        while (hasNext())
        {
        	Record record = nextRecord();
        	if(record==null)
        	{
        		System.err.println("WARNING: The line "+ (lastLine+1) + " has been deleted from the testing file.");
        		linesDeleted.add(lastLine);
            	continue;
        	}
        	lastLine++;
        	
            INDArray transformed = vasttextTextVectorizer.transform(record);
            
            org.datavec.api.records.impl.Record transformedRecord = new org.datavec.api.records.impl.Record(
            				new ArrayList<>(Collections.<Writable>singletonList(new NDArrayWritable(transformed))),
                            new RecordMetaDataURI(record.getMetaData().getURI(), VasttextTextFileReader.class));

            if (labelled)
            	transformedRecord.getRecord().add(record.getRecord().get(record.getRecord().size() - 1));

            records.add(transformedRecord);
        }

        recordIter = records.iterator();
    }
    this.initialized = true;
}
 
Example 16
Source File: TfidfVectorizer.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(Configuration conf){
    super.initialize(conf);
    this.smooth_idf = conf.getBoolean(SMOOTH_IDF, true);
}