机器学习AI之mxnet c++随笔(5)

#include
#include
#include “mxnet-cpp/MxNetCpp.h”
//email:[email protected]
//code:liuxing
using namespace std;
using namespace mxnet::cpp;
Symbol myNet(){
auto x=Symbol::Variable(“X”);
auto y=Symbol::Variable(“Y”);
auto z=Symbol::Variable(“Z”);
z=x+y;
return z;
}
int main(){
std::map args;
Context ctx = Context::cpu();
auto dataX=NDArray(Shape(1), ctx);
auto dataY=NDArray(Shape(1), ctx);
dataX=12.5;
dataY=22.9;
args[“X”]=dataX;
args[“Y”]=dataY;
auto net=myNet();
auto *exe=net.SimpleBind(ctx,args);
exe->Forward(false);
std::vector& out = exe->outputs;
cout< cout< delete exe;
}

$make learn1
$build/learn1

1
[35.4, ]

你可能感兴趣的:(AI,机器学习&AI之c++随笔)