コード例 #1
0
        /// <summary>
        /// Creates a new instance with default arguments for supervised training.
        /// </summary>
        /// <param name="builder">An optional action to change some params.</param>
        public static TrainingArgs SupervisedDefaults(Action <TrainingArgs> builder = null)
        {
            var result = new TrainingArgs
            {
                LearningRate  = 0.1,
                MaxCharNGrams = 0,
                MinCharNGrams = 0
            };

            builder?.Invoke(result);

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Trains a new model.
        /// </summary>
        /// <param name="inputPath">Path to a training set.</param>
        /// <param name="outputPath">Path to write the model to (excluding extension).</param>
        /// <param name="args">Training arguments.</param>
        /// <remarks>Trained model will consist of two files: .bin (main model) and .vec (word vectors).</remarks>
        public void Train(string inputPath, string outputPath, TrainingArgs args)
        {
            var argsStruct = new TrainingArgsStruct
            {
                Epochs        = args.Epochs,
                LearningRate  = args.LearningRate,
                MaxCharNGrams = args.MaxCharNGrams,
                MinCharNGrams = args.MinCharNGrams,
                Verbose       = args.Verbose,
                WordNGrams    = args.WordNGrams
            };

            TrainSupervised(_fastText, inputPath, outputPath, argsStruct, args.LabelPrefix);
            _maxLabelLen = GetMaxLabelLenght(_fastText);
        }