【发布时间】:2017-09-11 09:24:41
【问题描述】:
我正在尝试按照官方指南在 tensorflow 中定义新的运算符。 https://www.tensorflow.org/extend/adding_an_op
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/shape_inference.h"
using namespace tensorflow;
REGISTER_OP("ZeroOut")
.Input("to_zero: int32")
.Output("zeroed: int32")
.SetShapeFn([](::tensorflow::shape_inference::InferenceContext* c){
c->set_output(0, c->input(0));
return Status::OK();
});
但是我找不到此代码的逐行解释,特别是我不明白 .SetShapeFn([](::tensorflow::shape_inference::InferenceContext* c) 的作用及其语法.我也对InferenceContext感到困惑,我猜这是一种连续传递任何数组元素的方法..我在任何地方都找不到明确的定义,也许我找错了地方,有人能帮忙吗我有解释还是参考? 我想深入了解这段代码在后台做了什么。
【问题讨论】:
标签: tensorflow operators