public void Recover(Config conf, DataSet train) { _train = train; _conf = conf; FixedParams.AddRange(_surface.SubmitParameters()); FixedParams.AddRange(_act.SubmitParameters()); FixedParams.AddRange(_label.SubmitParameters()); FixedParams.AddRange(_actOutput.SubmitParameters()); FixedParams.AddRange(_labelOutput.SubmitParameters()); FixedParams.Add(_non); AllParams.AddRange(FixedParams); AllParams.AddRange(_formemb); AllParams.AddRange(_posemb); switch (_conf.OptType) { case OptType.sgd: _opt = new Sgd(_conf.LearningRate, _conf.L2RegFactor, _conf.ClipBound, _conf.DecayRate, train.Count); break; case OptType.adagrad: _opt = new AdaGrad(_conf.LearningRate, _conf.L2RegFactor, _conf.ClipBound, _conf.Eps); break; case OptType.adam: _opt = new Adam(_conf.LearningRate, _conf.L2RegFactor, _conf.ClipBound, 0.999f, 0.9f, 1e-8f); break; default: throw new ArgumentOutOfRangeException(nameof(_conf.OptType), "unknown opt type"); } }
double GetProgressFunctionValue(int x) { var expression = Procedure.ProgressFunction; foreach (var param in AllParams) { expression = expression.Replace(param.Key, param.Value); } expression = expression.Replace("[x]", x.ToString()); // if (expression.Contains("design_object_complexity")) if (AllParams.ContainsKey("[design_object_complexity]") && AllParams["[design_object_complexity]"] == null) { throw new SimulationException($"Укажите сложность ОП у процедуры {Procedure.Alias}"); } if (expression.Contains("[")) { throw new SimulationException($"Не хватает ресурсов у процедуры {Procedure.Alias}"); } var result = new Expression(expression).calculate(); return(result); }
public MLP(Config conf, DataSet train) { _train = train; _conf = conf; _rng = new RandomNumberGenerator(conf.Seed); _rngChoice = new RandomNumberGenerator(conf.Seed); _formemb = File.Exists(conf.EmbedFile) ? InitEmbed(conf.EmbedFile, train.Form, conf.InitRange) : InitEmbed(train.Form, conf.InitRange); _posemb = InitEmbed(train.PosTag, conf.InitRange); _non = new Tensor(1, conf.HiddenSize * 2, true); _surface = new BiLstmUnit(conf.EmbeddingSize * 2, conf.HiddenSize); _act = new DenseUnit(conf.HiddenSize * 6, conf.HiddenSize); _actOutput = new DenseUnit(conf.HiddenSize, 3); _label = new DenseUnit(conf.HiddenSize * 6, conf.HiddenSize); _labelOutput = new DenseUnit(conf.HiddenSize * 3, train.DepLabel.Count); FixedParams.AddRange(_surface.SubmitParameters()); FixedParams.AddRange(_act.SubmitParameters()); FixedParams.AddRange(_label.SubmitParameters()); FixedParams.AddRange(_actOutput.SubmitParameters()); FixedParams.AddRange(_labelOutput.SubmitParameters()); FixedParams.Add(_non); AllParams.AddRange(FixedParams); AllParams.AddRange(_formemb); AllParams.AddRange(_posemb); _surface.Init((fin, fout) => new GlorotNormalInit(fin, fout, _rng).Next); _act.Init((fin, fout) => new GlorotNormalInit(fin, fout, _rng).Next); _label.Init((fin, fout) => new GlorotNormalInit(fin, fout, _rng).Next); _actOutput.Init((fin, fout) => new GlorotNormalInit(fin, fout, _rng).Next); _labelOutput.Init((fin, fout) => new GlorotNormalInit(fin, fout, _rng).Next); switch (conf.OptType) { case OptType.sgd: _opt = new Sgd(conf.LearningRate, conf.L2RegFactor, conf.ClipBound, conf.DecayRate, train.Count); break; case OptType.adagrad: _opt = new AdaGrad(conf.LearningRate, conf.L2RegFactor, conf.ClipBound, conf.Eps); break; case OptType.adam: _opt = new Adam(conf.LearningRate, conf.L2RegFactor, conf.ClipBound, 0.999f, 0.9f, 1e-8f); break; default: throw new ArgumentOutOfRangeException(nameof(conf.OptType), "unknown opt type"); } _opt.Prepare(AllParams); G.SetRng(conf.Seed); }
public ArrayInstance All(object allParams) { var parameters = new AllParams(this.Engine.Object.InstancePrototype); if (allParams != null && allParams != Undefined.Value && allParams != Null.Value) { parameters = JurassicHelper.Coerce <AllParams>(this.Engine, allParams); } string sql = BuildSelect(parameters.Where, parameters.OrderBy, parameters.Limit); return(Query(string.Format(sql, parameters.Columns, GetFullTableName()), parameters.Args)); }
public override AllParams UseSkill() { var param = new AllParams() { healthBuff = this.healthBuff, attackBuff = this.attackBuff, speedBuff = this.speedBuff, buffDelay = this.buffDelay }; _skillActive.Init(); return(param); }
// attention: // If root object is accessed through the BuildContext object, use buildContext.TryGetVariable method instead. internal Variable TryGetVariable( string variableName, out QueryTalkException exception, Variable.SearchType searchType = Variable.SearchType.Any) { exception = null; if (variableName == null) { exception = Variable.InvalidVariableException(variableName, QueryTalkExceptionType.ArgumentNull); return(null); } Variable param; Variable variable; // try get param param = AllParams.Where(p => p.Name.EqualsCS(variableName)) .FirstOrDefault(); // try get non-param variable = _variables.Where(v => v.Name.EqualsCS(variableName)) .FirstOrDefault(); if (searchType == Variable.SearchType.Any) { return(param ?? variable); } if (searchType == Variable.SearchType.Inliner && (param == null || param.DT.IsNotInliner())) { exception = Variable.InvalidVariableException(variableName, QueryTalkExceptionType.InlinerNotFound); return(null); } // param/variable should exists if (searchType != Variable.SearchType.Any && (param == null && variable == null)) { exception = Variable.InvalidVariableException(variableName, QueryTalkExceptionType.ParamOrVariableNotDeclared); return(null); } return(param ?? variable); }
private void LoadFromFile(string filePath) { Regex regex = new Regex(@"(?<name>\w+) = (?<value>\S+)"); _allParams = new AllParams(); var type = _allParams.GetType(); foreach (Match match in regex.Matches(File.ReadAllText(filePath))) { var fieldName = match.Groups["name"].Value; var fieldValue = match.Groups["value"].Value; var fieldType = type.GetField(fieldName).FieldType; type.GetField(fieldName).SetValue(_allParams, ResolveValueType(fieldType, fieldValue)); } }