使用CNTK 2.1.0 GPU的学习率设置,vs 2015 Update 3,C ,窗口
learning rate setting with CNTK 2.1.0 GPU, VS 2015 update 3, C++, Window
i转介" https://github.com/microsoft/cntk/cntk/blob/master/master/tests/unittests/v2librarytests/feedforwardtests.cpp"
在" TestFeedForwardNetworkCreation"功能中,我找不到设置学习率的方法。
std::vector<float> inputData(inputDim * numSamples);
for (size_t i2 = 0; i2 < inputData.size(); ++i2)
inputData[i2] = ((float)rand()) / RAND_MAX;
NDShape inputShape = inputVar.Shape().AppendShape({ 1, numSamples });
ValuePtr inputValue = MakeSharedObject<Value>(MakeSharedObject<NDArrayView>(inputShape, inputData.data(), inputData.size(), DeviceDescriptor::CPUDevice(), true));
std::vector<float> labelData(numOutputClasses * numSamples, 0);
for (size_t i3 = 0; i3 < numSamples; ++i3)
labelData[(i3*numOutputClasses) + (rand() % numOutputClasses)] = 1;
NDShape labelShape = labelsVar.Shape().AppendShape({ 1, numSamples });
ValuePtr labelValue = MakeSharedObject<Value>(MakeSharedObject<NDArrayView>(labelShape, labelData.data(), labelData.size(), DeviceDescriptor::CPUDevice(), true));
ValuePtr outputValue, predictionErrorValue;
std::unordered_map<Variable, ValuePtr> outputs = { { classifierOutput, outputValue }, { prediction, predictionErrorValue } };
auto backpropState = ffNet->Forward({ { inputVar, inputValue }, { labelsVar, labelValue } }, outputs, device, { trainingLoss });
// Perform backprop
NDShape outputShape = trainingLoss->Output().Shape();
std::vector<float> rootGradientsData(outputShape.TotalSize(), 1);
ValuePtr rootGradientValue = MakeSharedObject<Value>(MakeSharedObject<NDArrayView>(outputShape, rootGradientsData.data(), rootGradientsData.size(), DeviceDescriptor::CPUDevice(), true));
std::unordered_map<Variable, ValuePtr> paramGradients;
auto allParams = ffNet->Parameters();
for (auto iter = allParams.begin(); iter != allParams.end(); ++iter)
paramGradients[*iter] = nullptr;
ffNet->Backward(backpropState, { { trainingLoss, rootGradientValue } }, paramGradients);
在学习者的构造师中指定学习率或学习率表。请参阅此处。
相关文章:
- vs 2015 constexpr变量不恒定,但与2019相比还好吗
- 从VS 2015更新3更新到VS2015更新3 d后浮点计算行为不同的原因
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 如何使用VS 2015构建Boost 1.44
- 图标编辑器中的自定义颜色 (VS 2015)
- VS 2015 linking fltlib.lib
- C++不正确,不需要重新声明类成员变量 MFC 手工解决方案/项目 MS VS 2015
- VS Express 2015 Win10 应用程序 - ifstream 无法打开文件
- VisualStudio 2015 链接器查找 VS 2010 库
- 未报告的错误VS 2015:十六进制字符说明符
- asm inline vs 2015 with call RegCreateKeyEx
- 使用 VS 2015 的编译器警告 4456
- VS 2013 和 VS 2015 的不同C++可再发行 DLL
- C ,vs 2015,致命错误:重复资源.类型:清单,名称:1,语言:0x0409
- 'cv':构建时不存在具有此名称的命名空间(VS 2015,OpenCV 3.2)
- 在VS 2015中使用Microchip的mpusbapi.h会产生"LNK2005 Already defined"错误
- 自定义分配器仅在VS 2015中的发布模式下编译
- VS 2015 "Build Dependencies -> Build Customization"总是触发预构建和后期构建
- MySQL C++连接器未解析的依赖项(VS 2015)
- LLVM:VS 2015 中的链接错误