A document of markdown, code and rich outputs, written as a Jupyter notebook (nbformat 4.5) or as one self-contained HTML page. Neither needs Python or a kernel: the notebook renders on GitHub, in JupyterLab, VS Code and Quarto with its outputs already in place. The title becomes a heading cell at the top.
More...
#include <report.hpp>
|
| | Report (std::string title="") |
| |
| Report & | markdown (std::string text) |
| | A markdown cell.
|
| |
| Report & | code (std::string source) |
| | A code cell showing source as C++ (not run).
|
| |
| Report & | output (MimeBundle bundle) |
| | A rich output: attached to the last cell if it is a code cell, otherwise in a code cell of its own.
|
| |
| template<class T > |
| Report & | show (const T &value) |
| | output(mime_bundle_repr(value)).
|
| |
| Report & | text (std::string text) |
| | A plain-text output (a stream output on stdout in the notebook).
|
| |
| const std::string & | title () const |
| |
| size_t | num_cells () const |
| |
| std::string | to_ipynb () const |
| | The notebook as nbformat 4.5 JSON. Its kernel spec is xeus-cpp's C++17 kernel, so the code cells run there if someone wants to.
|
| |
| std::string | to_html (const HtmlOptions &options={}) const |
| | One HTML page. Vega-Lite charts load Vega from the CDN (pinned, with integrity hashes) or, with HtmlScripts::Inline, embed it; a report without charts has no script.
|
| |
| void | save_ipynb (const std::string &path) const |
| |
| void | save_html (const std::string &path, const HtmlOptions &options={}) const |
| |
A document of markdown, code and rich outputs, written as a Jupyter notebook (nbformat 4.5) or as one self-contained HTML page. Neither needs Python or a kernel: the notebook renders on GitHub, in JupyterLab, VS Code and Quarto with its outputs already in place. The title becomes a heading cell at the top.
Report report(
"LRP on ResNet18");
report.markdown("We explain the top class with **EpsilonPlus**.")
.code("Attribution a = LRP::epsilon_plus().explain(ctx, x, target, &backend);")
.show(a);
report.save_ipynb("resnet18.ipynb");
report.save_html("resnet18.html");
static LRP epsilon_plus(float epsilon=1e-6f)
Zennit EpsilonPlus preset (lrp_composite::epsilon_plus).
Definition lrp.hpp:188
Attribution explain(ExplainerContext &ctx, const Tensor &input, int64_t target_index, DeviceBackend *backend) const
Explains target_index for every row, OutputValue seed.
Definition lrp.hpp:201
A document of markdown, code and rich outputs, written as a Jupyter notebook (nbformat 4....
Definition report.hpp:41
An explanation result: the raw attribution values, the method that produced them, and any relevant me...
Definition attribution.hpp:23
- Code is shown, not run. A code cell holds its source as text with no execution count.
- Outputs attach to the code cell before them. An output with no code cell before it gets a code cell of its own with no source, whose input is hidden in JupyterLab.
- The notebook is deterministic: cell ids are numbered (
cell-1, cell-2, ...), so the same report always writes the same bytes.
- The HTML page renders the markdown (the subset described at to_html()) with any raw HTML in it escaped, shows code in
<pre> blocks, and shows each output in its richest format that needs no kernel: Vega-Lite charts through vega-embed, then SVG, PNG, HTML and text.
◆ Report()
| pulsatrix::Report::Report |
( |
std::string |
title = "" | ) |
|
|
explicit |
◆ code()
| Report & pulsatrix::Report::code |
( |
std::string |
source | ) |
|
A code cell showing source as C++ (not run).
◆ markdown()
| Report & pulsatrix::Report::markdown |
( |
std::string |
text | ) |
|
◆ num_cells()
| size_t pulsatrix::Report::num_cells |
( |
| ) |
const |
|
inline |
◆ output()
A rich output: attached to the last cell if it is a code cell, otherwise in a code cell of its own.
- Exceptions
-
| std::invalid_argument | for an empty bundle. |
◆ save_html()
| void pulsatrix::Report::save_html |
( |
const std::string & |
path, |
|
|
const HtmlOptions & |
options = {} |
|
) |
| const |
- Exceptions
-
| std::runtime_error | if the file can't be written. |
◆ save_ipynb()
| void pulsatrix::Report::save_ipynb |
( |
const std::string & |
path | ) |
const |
- Exceptions
-
| std::runtime_error | if the file can't be written. |
◆ show()
template<class T >
| Report & pulsatrix::Report::show |
( |
const T & |
value | ) |
|
|
inline |
output(mime_bundle_repr(value)).
◆ text()
| Report & pulsatrix::Report::text |
( |
std::string |
text | ) |
|
A plain-text output (a stream output on stdout in the notebook).
◆ title()
| const std::string & pulsatrix::Report::title |
( |
| ) |
const |
|
inline |
◆ to_html()
| std::string pulsatrix::Report::to_html |
( |
const HtmlOptions & |
options = {} | ) |
const |
One HTML page. Vega-Lite charts load Vega from the CDN (pinned, with integrity hashes) or, with HtmlScripts::Inline, embed it; a report without charts has no script.
- Note
- Markdown subset: ATX headings, paragraphs,
-, * and 1. lists, fenced code, pipe tables, **bold**, *italic*, `code` and [links](url); links only to http, https, mailto and relative URLs. Jupyter renders the notebook's markdown in full.
◆ to_ipynb()
| std::string pulsatrix::Report::to_ipynb |
( |
| ) |
const |
The notebook as nbformat 4.5 JSON. Its kernel spec is xeus-cpp's C++17 kernel, so the code cells run there if someone wants to.
The documentation for this class was generated from the following file: