Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion graph/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,15 @@ std::string CalcAllGradNormAction::to_string() const {
return oss.str();
}

std::string CalcAllGradNormAction::get_dot_string() const {
std::ostringstream oss;
oss << "Action_" << action_id << " -> Tensor_" << res->get_id() << ";" << std::endl;
for (const auto& grad : grads) {
oss << "Tensor_" << grad->get_id() << " -> Action_" << action_id << ";" << std::endl;
}
return oss.str();
}

void ClipGradAction::execute() {
assert(lhs != nullptr); // grad
assert(rhs != nullptr); // norm
Expand All @@ -391,6 +400,14 @@ std::string ClipGradAction::to_string() const {
return oss.str();
}

std::string ClipGradAction::get_dot_string() const {
std::ostringstream oss;
oss << "Action_" << action_id << " -> Tensor_" << lhs->get_id() << ";" << std::endl;
oss << "Tensor_" << rhs->get_id() << "-> Action_" << action_id << ";" << std::endl;
return oss.str();

}

void AdamStepAction::execute() {
param->inc_t();
int t = param->get_t();
Expand Down Expand Up @@ -1015,7 +1032,7 @@ void printDotGraph() {
// build edge
auto parent = tensor_view->get_parent();
if (parent != nullptr) {
out << "Tensor_" << parent->get_id() << " -> Tensor_" << tensor_view->get_id() << ";" << std::endl;
out << "Tensor_" << parent->get_id() << " -> Tensor_" << tensor_view->get_id() << "[style=dashed, dir=none];" << std::endl;
}
}

Expand Down
2 changes: 2 additions & 0 deletions graph/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class CalcAllGradNormAction : public Action {
return "CalcAllGradNormAction";
}
std::string to_string() const override;
std::string get_dot_string() const override;
private:
std::vector<Tensor*> grads;
};
Expand All @@ -228,6 +229,7 @@ class ClipGradAction : public Action {
return "ClipGradAction";
}
std::string to_string() const override;
std::string get_dot_string() const override;
private:
float grad_clip_val;
};
Expand Down
Binary file modified handwritten_recognition_topo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.