本文整理汇总了C++中tensor_type::set方法的典型用法代码示例。如果您正苦于以下问题:C++ tensor_type::set方法的具体用法?C++ tensor_type::set怎么用?C++ tensor_type::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensor_type
的用法示例。
在下文中一共展示了tensor_type::set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator ()(const tensor_type &x, tensor_type &y) {
// y = F ∗ x + b
for (auto i = 0; i < y.shape().at(0); ++i) {
for (auto j = 0; j < y.shape().at(1); ++j) {
for (auto s = 0; s < filter_.shape().at(0); ++s) {
for (auto t = 0; t < filter_.shape().at(1); ++t) {
for (auto u = 0; u < y.shape().at(2); ++u) {
F output_value = F(1) * y.at({i, j, u});
for (auto v = 0; v < filter_.shape().at(3); ++v) {
output_value += F(1) * filter_.at({s, t, u, v}) * x.at({i + s, j + t, v});
}
y.set({i, j, u}, output_value);
}
}
}
}
}
for (auto i = 0; i < y.shape().at(0); ++i) {
for (auto j = 0; j < y.shape().at(1); ++j) {
for (auto k = 0; k < y.shape().at(2); ++k) {
y.set({i, j, k}, F(1) * y.at({i, j, k}) + F(1) * bias_.at({k}));
}
}
}
}
示例2: operator
void operator ()(const tensor_type &delta, const tensor_type &x, tensor_type &x_gradient) {
CHECK_EQ(x.order(), delta.order());
// TODO(robertsdionne): Support arbitrary tensor order with an n-dimensional iterator.
for (auto i = 0; i < x.shape().at(0); ++i) {
for (auto j = 0; j < x.shape().at(1); ++j) {
x_gradient.set({i, j}, delta.at({i, j}) * (x.at({i, j}) > F(0)));
}
}
}
示例3: operator
void operator ()(const tensor_type &x, tensor_type &y) {
using std::max;
CHECK_EQ(x.order(), y.order());
// TODO(robertsdionne): Support arbitrary tensor order with an n-dimensional iterator.
for (auto i = 0; i < x.shape().at(0); ++i) {
for (auto j = 0; j < x.shape().at(1); ++j) {
y.set({i, j}, max(F(0), x.at({i, j})));
}
}
}