internal static ParameterVector AsParameterVector(IList <Parameter> input) { ParameterVector inputVector = new ParameterVector(); foreach (var element in input) { inputVector.Add(element); } return(inputVector); }
internal static IList <Parameter> FromParameterVector(ParameterVector parameterVector) { IList <Parameter> parameterList = new List <Parameter>(); foreach (var parameter in parameterVector) { parameterList.Add(parameter); } return(parameterList); }
/// <summary> /// create a momentum SGD learner /// </summary> /// <param name="parameters">parameters to learn</param> /// <param name="learningRateSchedule">learning rate schedule</param> /// <param name="momentumSchedule">momentum schedule</param> /// <param name="unitGain">unit gain</param> /// <param name="additionalOptions">other additional options</param> /// <returns></returns> public static Learner MomentumSGDLearner(IList <Parameter> parameters, TrainingParameterScheduleDouble learningRateSchedule, TrainingParameterScheduleDouble momentumSchedule, bool unitGain, AdditionalLearningOptions additionalOptions = null) { if (additionalOptions == null) { additionalOptions = new AdditionalLearningOptions(); } ParameterVector parameterVector = Helper.AsParameterVector(parameters); return(CNTKLib.MomentumSGDLearner(parameterVector, learningRateSchedule, momentumSchedule, unitGain, additionalOptions)); }
/// <summary> /// Create an instance of the CNTK built-in SGD learner. /// </summary> /// <param name="parameters">Parameters of the learner.</param> /// <param name="learningRateSchedule">Learning rate schedule.</param> /// <param name="additionalOptions">Additional options.</param> /// <returns></returns> public static Learner SGDLearner(IList <Parameter> parameters, TrainingParameterScheduleDouble learningRateSchedule, AdditionalLearningOptions additionalOptions = null) { ParameterVector parameterVector = Helper.AsParameterVector(parameters); if (additionalOptions == null) { return(CNTKLib.SGDLearner(parameterVector, learningRateSchedule)); } else { return(CNTKLib.SGDLearner(parameterVector, learningRateSchedule, additionalOptions)); } }
/// <summary> /// Parameters if the function /// </summary> /// <returns></returns> public IList <Parameter> Parameters() { ParameterVector parameterVector = _Parameters(); return(Helper.FromParameterVector(parameterVector)); }
/// <summary> /// Create an instance of the CNTK built-in SGD learner. /// </summary> /// <param name="parameters">Parameters of the learner.</param> /// <param name="learningRateSchedule">Learning rate schedule.</param> /// <param name="additionalOptions">Additional options.</param> /// <returns></returns> public static Learner SGDLearner(IList <Parameter> parameters, TrainingParameterScheduleDouble learningRateSchedule, AdditionalLearningOptions additionalOptions) { ParameterVector parameterVector = Helper.AsParameterVector(parameters); return(SGDLearner(parameterVector, learningRateSchedule, additionalOptions)); }