mirror of
https://github.com/marian-nmt/marian.git
synced 2024-09-11 14:26:37 +03:00
Added comment
This commit is contained in:
parent
5dfae976a2
commit
1e2fec4bc2
@ -27,7 +27,13 @@ ExpressionGraphPtr FeedforwardClassifier(const std::vector<int>& dims) {
|
||||
|
||||
// Construct a shared pointer to an empty expression graph
|
||||
ExpressionGraphPtr g(new ExpressionGraph());
|
||||
|
||||
// Construct an Expr object to represent the input layer: g->input(...)
|
||||
// Assign this newly created object the name "x" and add it to the expression graph: named(..., "x")
|
||||
// And assign the resulting named Expr object to the C++ variable x
|
||||
auto x = named(g->input(shape={whatevs, dims.front()}), "x");
|
||||
|
||||
// Likewise, create a named Expr object called "y" for the output layer
|
||||
auto y = named(g->input(shape={whatevs, dims.back()}), "y");
|
||||
|
||||
std::vector<Expr> layers, weights, biases;
|
||||
@ -48,11 +54,13 @@ ExpressionGraphPtr FeedforwardClassifier(const std::vector<int>& dims) {
|
||||
}
|
||||
|
||||
auto linear = dot(layers.back(), weights.back()) + biases.back();
|
||||
auto scores = named(inference(softmax(linear)), "scores");
|
||||
|
||||
// @TODO: throw exception if more than one final training node
|
||||
// and keep track of training nodes, as we need to initialize
|
||||
// adjoints correctly.
|
||||
auto cost = named(mean(training(cross_entropy(linear, y)), axis=0), "cost");
|
||||
|
||||
auto scores = named(inference(softmax(linear)), "scores");
|
||||
|
||||
std::cerr << "\tTotal time: " << timer.format(5, "%ws") << std::endl;
|
||||
return g;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user