stanfordnlp/CoreNLP · error · RuntimeException
Could not read from double initial LOP scales file
Error message
Could not read from double initial LOP scales file
What it means
trainWeights reads initial LOP scales from flags.initialLopScales through a gzipped DataInputStream; an IOException there is wrapped in this RuntimeException. The configured scales file exists but could not be read or decoded as the expected double array format.
Solutions
- Verify flags.initialLopScales points to a valid gzip file produced by the same library version (gunzip -t to test).
- Regenerate the scales file with the same Stanford NLP Core version you are training with.
- Check read permissions and that the path resolves from the training working directory.
- Unset initialLopScales to let training initialize scales itself if no prior scales are required.
Example fix
// before initialLopScales=scales.gz // file from an older core version // after initialLopScales=/abs/path/scales_v4.gz // regenerated with current version // verify: gunzip -t scales_v4.gz
Defensive patterns
Strategy: validation
Validate before calling
File f = new File(flags.initialLopScales);
if (!f.isFile() || !f.canRead() || !isGzip(f))
throw new IllegalArgumentException("initialLopScales missing or not gzip: " + f.getAbsolutePath());
// isGzip: first two bytes == 0x1f 0x8b Type guard
static boolean isGzip(File f) throws IOException {
try (InputStream in = new BufferedInputStream(new FileInputStream(f))) {
int b0 = in.read(), b1 = in.read();
return b0 == 0x1f && b1 == (byte)0x8b;
}
} Try / catch
try {
trainer.train();
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Could not read from double initial LOP scales file")) {
props.remove("initialLopScales"); // fall back to default scale init
trainer.train();
} else throw e;
} Prevention
- Verify gzip integrity (gunzip -t) before training.
- Generate scales files with the same library version used for training.
- Make initialLopScales optional in your pipeline so bad files can be dropped.
When it happens
Trigger: flags.initialLopScales set to a missing, unreadable, or corrupt (not valid gzip / wrong binary layout) file; stream fails partway so readDoubleArr throws IOException.
Common situations: Scales file written by a different NLP Core version or different Convert/ConvertByteArray binary layout, corrupt download, wrong file supplied, or path/permission problems.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Could not read from float initial weight file
- Could not read from double initial weight file
- Could not read from double initial LOP weights file
- error loading
- Unknown prior type:
AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10).
Data as JSON: /api/errors/60a7870065840f64.
Report an issue: GitHub.
Appendix: source
Thrown at src/edu/stanford/nlp/ie/crf/CRFClassifierWithLOP.java:209
// Arrays.fill(lopScales, 1.0);
CRFLogConditionalObjectiveFunctionForLOP func = new CRFLogConditionalObjectiveFunctionForLOP(data, labels, lopExpertWeights,
windowSize, classIndex, labelIndices, map, flags.backgroundSymbol, numLopExpert, featureIndicesSetArray, featureIndicesListArray,
flags.backpropLopTraining);
cliquePotentialFunctionHelper = func;
Minimizer<DiffFunction> minimizer = getMinimizer(0, evaluators);
double[] initialScales;
//TODO(mengqiu) clean this part up when backpropLogTraining == true
if (flags.initialLopScales == null) {
initialScales = func.initial();
} else {
log.info("Reading initial LOP scales from file " + flags.initialLopScales);
try (DataInputStream dis = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(
flags.initialLopScales))))) {
initialScales = ConvertByteArray.readDoubleArr(dis);
} catch (IOException e) {
throw new RuntimeException("Could not read from double initial LOP scales file " + flags.initialLopScales);
}
}
double[] learnedParams = minimizer.minimize(func, flags.tolerance, initialScales);
double[] rawScales = func.separateLopScales(learnedParams);
double[] lopScales = ArrayMath.softmax(rawScales);
log.info("After SoftMax Transformation, learned scales are:");
for (int lopIter = 0; lopIter < numLopExpert; lopIter++) {
log.info("lopScales[" + lopIter + "] = " + lopScales[lopIter]);
}
double[][] learnedLopExpertWeights = lopExpertWeights;
if (flags.backpropLopTraining) {
learnedLopExpertWeights = func.separateLopExpertWeights(learnedParams);
}
return CRFLogConditionalObjectiveFunctionForLOP.combineAndScaleLopWeights(numLopExpert, learnedLopExpertWeights, lopScales);
}
} // end class CRFClassifierWithLOPView on GitHub (pinned to 1b7edd19c4)