{"record":{"id":"40c673f89669f42d","repo":"stanfordnlp/CoreNLP","slug":"could-not-read-from-double-initial-lop-weights-fil","errorCode":null,"errorMessage":"Could not read from double initial LOP weights file ","messagePattern":"Could not read from double initial LOP weights file ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/crf/CRFClassifierWithLOP.java","lineNumber":155,"sourceCode":"        List<double[]> listOfWeights = new ArrayList<>(numLopExpert);\n        for (String line; (line = br.readLine()) != null; ) {\n          line = line.trim();\n          String[] parts = line.split(\"\\t\");\n          double[] wArr = new double[parts.length];\n          for (int i = 0; i < parts.length; i++) {\n            wArr[i] = Double.parseDouble(parts[i]);\n          }\n          listOfWeights.add(wArr);\n        }\n        assert(listOfWeights.size() == numLopExpert);\n        log.info(\"Done!\");\n        for (int i = 0; i < numLopExpert; i++)\n          lopExpertWeights[i] = listOfWeights.get(i);\n        // DataInputStream dis = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(\n        //     flags.initialLopWeights))));\n        // initialScales = Convert.readDoubleArr(dis);\n      } catch (IOException e) {\n        throw new RuntimeException(\"Could not read from double initial LOP weights file \" + flags.initialLopWeights);\n      }\n    } else {\n      for (int lopIter = 0; lopIter < numLopExpert; lopIter++) {\n        int[][][][] partialData = createPartialDataForLOP(lopIter, data);\n        if (flags.randomLopWeights) {\n          lopExpertWeights[lopIter] = super.getObjectiveFunction(partialData, labels).initial();\n        } else {\n          lopExpertWeights[lopIter] = super.trainWeights(partialData, labels, evaluators, pruneFeatureItr, null);\n        }\n      }\n      if (flags.includeFullCRFInLOP) {\n        double[][] newLopExpertWeights = new double[numLopExpert+1][];\n        System.arraycopy(lopExpertWeights, 0, newLopExpertWeights, 0, lopExpertWeights.length);\n        if (flags.randomLopWeights) {\n          newLopExpertWeights[numLopExpert] = super.getObjectiveFunction(data, labels).initial();\n        } else {\n          newLopExpertWeights[numLopExpert] = super.trainWeights(data, labels, evaluators, pruneFeatureItr, null);\n        }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/crf/CRFClassifierWithLOP.java#L137-L173","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check flags.initialLopWeights points to an existing, readable file relative to the training process's working directory.","Fix the path in your training properties/flags (use an absolute path to rule out CWD issues).","Verify file permissions (chmod/read access) for the user running training.","If the file is gzip-compressed, confirm it is a valid gzip stream (gunzip -t).","If no initial weights are needed, unset flags.initialLopWeights so random or computed LOP weights are used instead."],"exampleFix":"// before (train.prop)\ninitialLopWeights=data/lop_weights.bin\n// after: absolute, verified path\ninitialLopWeights=/full/path/to/lop_weights.bin\n// and check first:\n// new File(\"/full/path/to/lop_weights.bin\").canRead()","handlingStrategy":"validation","validationCode":"File f = new File(flags.initialLopWeights);\nif (!f.isFile() || !f.canRead())\n  throw new IllegalArgumentException(\"initialLopWeights not readable: \" + f.getAbsolutePath());","typeGuard":null,"tryCatchPattern":"try {\n  trainer.train();\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Could not read from double initial LOP weights file\")) {\n    log.error(\"Check initialLopWeights path: {}\", flags.initialLopWeights);\n    props.remove(\"initialLopWeights\"); // retrain with default init\n    trainer.train();\n  } else throw e;\n}","preventionTips":["Use absolute paths in training properties.","Check file existence/readability before launching long training runs.","Keep weights files under version control or a shared data store with checksums."],"tags":["io","file-not-found","training","configuration","crf"],"backgroundTag":"file-not-found","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}