1

ということで、POSTaggerのTrainning APIを使ってみました。しかし、新しいトレーニング済みデータを古いモデルに追加したいと思います。または、複数回トレーニングしたい場合は、多くのモデル ファイルが必要になります。結果を既存のモデルに戻すにはどうすればよいでしょうか。したがって、より大きなデータを持つモデルは 1 つしかありません。モデルファイルはバイナリファイルだと思うので、この場合ファイルの追加が機能するかどうかはわかりません。

これが私のコードです


public class POSTraining {
    private final String outputModel;
    private InputStream dataIn;

    public POSTraining() throws IOException {
        outputModel = this.getClass().getResource("/model/en-pos-maxent.bin").getPath();
        dataIn = this.getClass().getResourceAsStream("/model/en-pos.train");
    }

    public static void main(String args[]) throws IOException {

        POSTraining posTraining = new POSTraining();
        posTraining.train();
    }

    public void train() {
        try {
            ObjectStream lineStream = new PlainTextByLineStream(dataIn, "UTF-8");
            ObjectStream sampleStream = new WordTagSampleStream(lineStream);

            TrainingParameters trainParams = new TrainingParameters();
            trainParams.put("model", ModelType.MAXENT.name());
            POSModel trainedModel = POSTaggerME.train("en", sampleStream, trainParams, null, null);

            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(outputModel));
            trainedModel.serialize(bufferedOutputStream);

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (dataIn != null) {
                try {
                    dataIn.close();
                } catch (IOException e) {
                    // Not an issue, training already finished.
                    // The exception should be logged and investigated
                    // if part of a production system.
                    e.printStackTrace();
                }
            }
        }


    }
}


4

1 に答える 1

0

これは、NLP モデルでは一般的に不可能です。それらを段階的に調整することはできません。

于 2012-08-22T21:50:18.957 に答える