stanfordnlp/CoreNLP · error · RuntimeException

Could not read from double initial LOP weights file

Error message

Could not read from double initial LOP weights file 

What it means

trainWeights tries to load initial LOP (log-linear opinion pool) expert weights from flags.initialLopWeights; any IOException while reading the file is rethrown as this RuntimeException. It means the configured initial weights file could not be opened or read.

Solutions

  1. Check flags.initialLopWeights points to an existing, readable file relative to the training process's working directory.
  2. Fix the path in your training properties/flags (use an absolute path to rule out CWD issues).
  3. Verify file permissions (chmod/read access) for the user running training.
  4. If the file is gzip-compressed, confirm it is a valid gzip stream (gunzip -t).
  5. If no initial weights are needed, unset flags.initialLopWeights so random or computed LOP weights are used instead.

Example fix

// before (train.prop)
initialLopWeights=data/lop_weights.bin
// after: absolute, verified path
initialLopWeights=/full/path/to/lop_weights.bin
// and check first:
// new File("/full/path/to/lop_weights.bin").canRead()
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(flags.initialLopWeights);
if (!f.isFile() || !f.canRead())
  throw new IllegalArgumentException("initialLopWeights not readable: " + f.getAbsolutePath());

Try / catch

try {
  trainer.train();
} catch (RuntimeException e) {
  if (e.getMessage() != null && e.getMessage().startsWith("Could not read from double initial LOP weights file")) {
    log.error("Check initialLopWeights path: {}", flags.initialLopWeights);
    props.remove("initialLopWeights"); // retrain with default init
    trainer.train();
  } else throw e;
}

Prevention

When it happens

Trigger: Training a CRFClassifierWithLOP with flags.initialLopWeights set to a path that does not exist, is unreadable (permissions), is a directory, or whose stream throws mid-read (e.g. corrupt gzip).

Common situations: Typo in the training property initialLopWeights, running training from a different working directory so relative paths break, file deleted between runs, or missing read permissions.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of stanfordnlp/CoreNLP@1b7edd19c4 (2026-09-10). Data as JSON: /api/errors/40c673f89669f42d. Report an issue: GitHub.

Appendix: source

Thrown at src/edu/stanford/nlp/ie/crf/CRFClassifierWithLOP.java:155

        List<double[]> listOfWeights = new ArrayList<>(numLopExpert);
        for (String line; (line = br.readLine()) != null; ) {
          line = line.trim();
          String[] parts = line.split("\t");
          double[] wArr = new double[parts.length];
          for (int i = 0; i < parts.length; i++) {
            wArr[i] = Double.parseDouble(parts[i]);
          }
          listOfWeights.add(wArr);
        }
        assert(listOfWeights.size() == numLopExpert);
        log.info("Done!");
        for (int i = 0; i < numLopExpert; i++)
          lopExpertWeights[i] = listOfWeights.get(i);
        // DataInputStream dis = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(
        //     flags.initialLopWeights))));
        // initialScales = Convert.readDoubleArr(dis);
      } catch (IOException e) {
        throw new RuntimeException("Could not read from double initial LOP weights file " + flags.initialLopWeights);
      }
    } else {
      for (int lopIter = 0; lopIter < numLopExpert; lopIter++) {
        int[][][][] partialData = createPartialDataForLOP(lopIter, data);
        if (flags.randomLopWeights) {
          lopExpertWeights[lopIter] = super.getObjectiveFunction(partialData, labels).initial();
        } else {
          lopExpertWeights[lopIter] = super.trainWeights(partialData, labels, evaluators, pruneFeatureItr, null);
        }
      }
      if (flags.includeFullCRFInLOP) {
        double[][] newLopExpertWeights = new double[numLopExpert+1][];
        System.arraycopy(lopExpertWeights, 0, newLopExpertWeights, 0, lopExpertWeights.length);
        if (flags.randomLopWeights) {
          newLopExpertWeights[numLopExpert] = super.getObjectiveFunction(data, labels).initial();
        } else {
          newLopExpertWeights[numLopExpert] = super.trainWeights(data, labels, evaluators, pruneFeatureItr, null);
        }

View on GitHub (pinned to 1b7edd19c4)