Skip to content

grid_display

GridDisplay

Bases: Trace

A Trace to display of grid of images.

Parameters:

Name Type Description Default
columns Sequence[BatchDisplay]

A list of BatchDisplay traces to be combined into a grid. Their batch_limit, frequency, save_dir, mode, and ds_id arguments will be ignored in favor of the ones provided to the GridDisplay.

required
batch_limit Optional[int]

A limit on the number of batch elements to display.

None
frequency Union[None, int, str]

'batch', 'epoch', integer, or strings like '10s', '15e'. When using 'batch', writes the losses and metrics to TensorBoard after each batch. The same applies for 'epoch'. If using an integer, let's say 1000, the callback will write the metrics and losses to TensorBoard every 1000 samples. You can also use strings like '8s' to indicate every 8 steps or '5e' to indicate every 5 epochs. You can use None to default to matching the log printing frequency.

None
save_dir Optional[str]

A directory into which to save images rather than displaying them. The file names will be formatted as <em><mode></em><epoch>_<batch_idx>.html</p> </div> </td> <td> <code>None</code> </td> </tr> <tr> <td><code>title</code></td> <td> <code>str</code> </td> <td> <div class="doc-md-description"> <p>The title prefix to use if save_dir is specified.</p> </div> </td> <td> <code>'grid'</code> </td> </tr> <tr> <td><code>mode</code></td> <td> <code><span title="typing.Union">Union</span>[None, str, <span title="typing.Iterable">Iterable</span>[str]]</code> </td> <td> <div class="doc-md-description"> <p>What mode(s) to execute this Trace in. For example, "train", "eval", "test", or "infer". To execute regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument like "!infer" or "!train".</p> </div> </td> <td> <code>None</code> </td> </tr> <tr> <td><code>ds_id</code></td> <td> <code><span title="typing.Union">Union</span>[None, str, <span title="typing.Iterable">Iterable</span>[str]]</code> </td> <td> <div class="doc-md-description"> <p>What dataset id(s) to execute this Trace in. To execute regardless of ds_id, pass None. To execute in all ds_ids except for a particular one, you can pass an argument like "!ds1".</p> </div> </td> <td> <code>None</code> </td> </tr> </tbody> </table> <details class="quote"> <summary>Source code in <code>fastestimator/fastestimator/trace/io/grid_display.py</code></summary> <div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-26">26</a></span> <span class="normal"><a href="#__codelineno-0-27">27</a></span> <span class="normal"><a href="#__codelineno-0-28">28</a></span> <span class="normal"><a href="#__codelineno-0-29">29</a></span> <span class="normal"><a href="#__codelineno-0-30">30</a></span> <span class="normal"><a href="#__codelineno-0-31">31</a></span> <span class="normal"><a href="#__codelineno-0-32">32</a></span> <span class="normal"><a href="#__codelineno-0-33">33</a></span> <span class="normal"><a href="#__codelineno-0-34">34</a></span> <span class="normal"><a href="#__codelineno-0-35">35</a></span> <span class="normal"><a href="#__codelineno-0-36">36</a></span> <span class="normal"><a href="#__codelineno-0-37">37</a></span> <span class="normal"><a href="#__codelineno-0-38">38</a></span> <span class="normal"><a href="#__codelineno-0-39">39</a></span> <span class="normal"><a href="#__codelineno-0-40">40</a></span> <span class="normal"><a href="#__codelineno-0-41">41</a></span> <span class="normal"><a href="#__codelineno-0-42">42</a></span> <span class="normal"><a href="#__codelineno-0-43">43</a></span> <span class="normal"><a href="#__codelineno-0-44">44</a></span> <span class="normal"><a href="#__codelineno-0-45">45</a></span> <span class="normal"><a href="#__codelineno-0-46">46</a></span> <span class="normal"><a href="#__codelineno-0-47">47</a></span> <span class="normal"><a href="#__codelineno-0-48">48</a></span> <span class="normal"><a href="#__codelineno-0-49">49</a></span> <span class="normal"><a href="#__codelineno-0-50">50</a></span> <span class="normal"><a href="#__codelineno-0-51">51</a></span> <span class="normal"><a href="#__codelineno-0-52">52</a></span> <span class="normal"><a href="#__codelineno-0-53">53</a></span> <span class="normal"><a href="#__codelineno-0-54">54</a></span> <span class="normal"><a href="#__codelineno-0-55">55</a></span> <span class="normal"><a href="#__codelineno-0-56">56</a></span> <span class="normal"><a href="#__codelineno-0-57">57</a></span> <span class="normal"><a href="#__codelineno-0-58">58</a></span> <span class="normal"><a href="#__codelineno-0-59">59</a></span> <span class="normal"><a href="#__codelineno-0-60">60</a></span> <span class="normal"><a href="#__codelineno-0-61">61</a></span> <span class="normal"><a href="#__codelineno-0-62">62</a></span> <span class="normal"><a href="#__codelineno-0-63">63</a></span> <span class="normal"><a href="#__codelineno-0-64">64</a></span> <span class="normal"><a href="#__codelineno-0-65">65</a></span> <span class="normal"><a href="#__codelineno-0-66">66</a></span> <span class="normal"><a href="#__codelineno-0-67">67</a></span> <span class="normal"><a href="#__codelineno-0-68">68</a></span> <span class="normal"><a href="#__codelineno-0-69">69</a></span> <span class="normal"><a href="#__codelineno-0-70">70</a></span> <span class="normal"><a href="#__codelineno-0-71">71</a></span> <span class="normal"><a href="#__codelineno-0-72">72</a></span> <span class="normal"><a href="#__codelineno-0-73">73</a></span> <span class="normal"><a href="#__codelineno-0-74">74</a></span> <span class="normal"><a href="#__codelineno-0-75">75</a></span> <span class="normal"><a href="#__codelineno-0-76">76</a></span> <span class="normal"><a href="#__codelineno-0-77">77</a></span> <span class="normal"><a href="#__codelineno-0-78">78</a></span> <span class="normal"><a href="#__codelineno-0-79">79</a></span> <span class="normal"><a href="#__codelineno-0-80">80</a></span> <span class="normal"><a href="#__codelineno-0-81">81</a></span> <span class="normal"><a href="#__codelineno-0-82">82</a></span> <span class="normal"><a href="#__codelineno-0-83">83</a></span> <span class="normal"><a href="#__codelineno-0-84">84</a></span> <span class="normal"><a href="#__codelineno-0-85">85</a></span> <span class="normal"><a href="#__codelineno-0-86">86</a></span> <span class="normal"><a href="#__codelineno-0-87">87</a></span> <span class="normal"><a href="#__codelineno-0-88">88</a></span> <span class="normal"><a href="#__codelineno-0-89">89</a></span> <span class="normal"><a href="#__codelineno-0-90">90</a></span> <span class="normal"><a href="#__codelineno-0-91">91</a></span> <span class="normal"><a href="#__codelineno-0-92">92</a></span> <span class="normal"><a href="#__codelineno-0-93">93</a></span> <span class="normal"><a href="#__codelineno-0-94">94</a></span> <span class="normal"><a href="#__codelineno-0-95">95</a></span></pre></div></td><td class="code"><div><pre><span></span><code><span id="__span-0-26"><a id="__codelineno-0-26" name="__codelineno-0-26"></a><span class="nd">@traceable</span><span class="p">()</span> </span><span id="__span-0-27"><a id="__codelineno-0-27" name="__codelineno-0-27"></a><span class="k">class</span> <span class="nc">GridDisplay</span><span class="p">(</span><span class="n">Trace</span><span class="p">):</span> </span><span id="__span-0-28"><a id="__codelineno-0-28" name="__codelineno-0-28"></a><span class="w"> </span><span class="sd">"""A Trace to display of grid of images.</span> </span><span id="__span-0-29"><a id="__codelineno-0-29" name="__codelineno-0-29"></a> </span><span id="__span-0-30"><a id="__codelineno-0-30" name="__codelineno-0-30"></a><span class="sd"> Args:</span> </span><span id="__span-0-31"><a id="__codelineno-0-31" name="__codelineno-0-31"></a><span class="sd"> columns: A list of BatchDisplay traces to be combined into a grid. Their batch_limit, frequency, save_dir,</span> </span><span id="__span-0-32"><a id="__codelineno-0-32" name="__codelineno-0-32"></a><span class="sd"> mode, and ds_id arguments will be ignored in favor of the ones provided to the GridDisplay.</span> </span><span id="__span-0-33"><a id="__codelineno-0-33" name="__codelineno-0-33"></a><span class="sd"> batch_limit: A limit on the number of batch elements to display.</span> </span><span id="__span-0-34"><a id="__codelineno-0-34" name="__codelineno-0-34"></a><span class="sd"> frequency: 'batch', 'epoch', integer, or strings like '10s', '15e'. When using 'batch', writes the losses and</span> </span><span id="__span-0-35"><a id="__codelineno-0-35" name="__codelineno-0-35"></a><span class="sd"> metrics to TensorBoard after each batch. The same applies for 'epoch'. If using an integer, let's say 1000,</span> </span><span id="__span-0-36"><a id="__codelineno-0-36" name="__codelineno-0-36"></a><span class="sd"> the callback will write the metrics and losses to TensorBoard every 1000 samples. You can also use strings</span> </span><span id="__span-0-37"><a id="__codelineno-0-37" name="__codelineno-0-37"></a><span class="sd"> like '8s' to indicate every 8 steps or '5e' to indicate every 5 epochs. You can use None to default to</span> </span><span id="__span-0-38"><a id="__codelineno-0-38" name="__codelineno-0-38"></a><span class="sd"> matching the log printing frequency.</span> </span><span id="__span-0-39"><a id="__codelineno-0-39" name="__codelineno-0-39"></a><span class="sd"> save_dir: A directory into which to save images rather than displaying them. The file names will be formatted</span> </span><span id="__span-0-40"><a id="__codelineno-0-40" name="__codelineno-0-40"></a><span class="sd"> as <title>_<mode>_<epoch>_<batch_idx>.html</span> </span><span id="__span-0-41"><a id="__codelineno-0-41" name="__codelineno-0-41"></a><span class="sd"> title: The title prefix to use if save_dir is specified.</span> </span><span id="__span-0-42"><a id="__codelineno-0-42" name="__codelineno-0-42"></a><span class="sd"> mode: What mode(s) to execute this Trace in. For example, "train", "eval", "test", or "infer". To execute</span> </span><span id="__span-0-43"><a id="__codelineno-0-43" name="__codelineno-0-43"></a><span class="sd"> regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument</span> </span><span id="__span-0-44"><a id="__codelineno-0-44" name="__codelineno-0-44"></a><span class="sd"> like "!infer" or "!train".</span> </span><span id="__span-0-45"><a id="__codelineno-0-45" name="__codelineno-0-45"></a><span class="sd"> ds_id: What dataset id(s) to execute this Trace in. To execute regardless of ds_id, pass None. To execute in all</span> </span><span id="__span-0-46"><a id="__codelineno-0-46" name="__codelineno-0-46"></a><span class="sd"> ds_ids except for a particular one, you can pass an argument like "!ds1".</span> </span><span id="__span-0-47"><a id="__codelineno-0-47" name="__codelineno-0-47"></a><span class="sd"> """</span> </span><span id="__span-0-48"><a id="__codelineno-0-48" name="__codelineno-0-48"></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> </span><span id="__span-0-49"><a id="__codelineno-0-49" name="__codelineno-0-49"></a> <span class="n">columns</span><span class="p">:</span> <span class="n">Sequence</span><span class="p">[</span><span class="n">BatchDisplay</span><span class="p">],</span> </span><span id="__span-0-50"><a id="__codelineno-0-50" name="__codelineno-0-50"></a> <span class="n">batch_limit</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> </span><span id="__span-0-51"><a id="__codelineno-0-51" name="__codelineno-0-51"></a> <span class="n">frequency</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> </span><span id="__span-0-52"><a id="__codelineno-0-52" name="__codelineno-0-52"></a> <span class="n">save_dir</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> </span><span id="__span-0-53"><a id="__codelineno-0-53" name="__codelineno-0-53"></a> <span class="n">title</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"grid"</span><span class="p">,</span> </span><span id="__span-0-54"><a id="__codelineno-0-54" name="__codelineno-0-54"></a> <span class="n">mode</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> </span><span id="__span-0-55"><a id="__codelineno-0-55" name="__codelineno-0-55"></a> <span class="n">ds_id</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="kc">None</span><span class="p">,</span> <span class="nb">str</span><span class="p">,</span> <span class="n">Iterable</span><span class="p">[</span><span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span> </span><span id="__span-0-56"><a id="__codelineno-0-56" name="__codelineno-0-56"></a> <span class="n">inputs</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span> </span><span id="__span-0-57"><a id="__codelineno-0-57" name="__codelineno-0-57"></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="n">columns</span><span class="p">:</span> </span><span id="__span-0-58"><a id="__codelineno-0-58" name="__codelineno-0-58"></a> <span class="n">inputs</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">column</span><span class="o">.</span><span class="n">inputs</span><span class="p">)</span> </span><span id="__span-0-59"><a id="__codelineno-0-59" name="__codelineno-0-59"></a> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">inputs</span><span class="o">=</span><span class="n">inputs</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span> <span class="n">ds_id</span><span class="o">=</span><span class="n">ds_id</span><span class="p">)</span> </span><span id="__span-0-60"><a id="__codelineno-0-60" name="__codelineno-0-60"></a> <span class="bp">self</span><span class="o">.</span><span class="n">_columns</span> <span class="o">=</span> <span class="n">columns</span> </span><span id="__span-0-61"><a id="__codelineno-0-61" name="__codelineno-0-61"></a> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span> <span class="o">=</span> <span class="kc">None</span> <span class="k">if</span> <span class="n">frequency</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">parse_freq</span><span class="p">(</span><span class="n">frequency</span><span class="p">)</span> </span><span id="__span-0-62"><a id="__codelineno-0-62" name="__codelineno-0-62"></a> <span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span> <span class="o">=</span> <span class="n">save_dir</span> </span><span id="__span-0-63"><a id="__codelineno-0-63" name="__codelineno-0-63"></a> <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">title</span> </span><span id="__span-0-64"><a id="__codelineno-0-64" name="__codelineno-0-64"></a> <span class="bp">self</span><span class="o">.</span><span class="n">batch_limit</span> <span class="o">=</span> <span class="n">batch_limit</span> </span><span id="__span-0-65"><a id="__codelineno-0-65" name="__codelineno-0-65"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span> </span><span id="__span-0-66"><a id="__codelineno-0-66" name="__codelineno-0-66"></a> <span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">normpath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span><span class="p">))</span> </span><span id="__span-0-67"><a id="__codelineno-0-67" name="__codelineno-0-67"></a> <span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span><span id="__span-0-68"><a id="__codelineno-0-68" name="__codelineno-0-68"></a> </span><span id="__span-0-69"><a id="__codelineno-0-69" name="__codelineno-0-69"></a> <span class="k">def</span> <span class="nf">on_begin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">:</span> <span class="n">Data</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> </span><span id="__span-0-70"><a id="__codelineno-0-70" name="__codelineno-0-70"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> </span><span id="__span-0-71"><a id="__codelineno-0-71" name="__codelineno-0-71"></a> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span> <span class="o">=</span> <span class="n">parse_freq</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">log_steps</span><span class="p">)</span> </span><span id="__span-0-72"><a id="__codelineno-0-72" name="__codelineno-0-72"></a> <span class="k">for</span> <span class="n">column</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_columns</span><span class="p">:</span> </span><span id="__span-0-73"><a id="__codelineno-0-73" name="__codelineno-0-73"></a> <span class="n">column</span><span class="o">.</span><span class="n">system</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">system</span> </span><span id="__span-0-74"><a id="__codelineno-0-74" name="__codelineno-0-74"></a> </span><span id="__span-0-75"><a id="__codelineno-0-75" name="__codelineno-0-75"></a> <span class="k">def</span> <span class="nf">on_batch_end</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">:</span> <span class="n">Data</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> </span><span id="__span-0-76"><a id="__codelineno-0-76" name="__codelineno-0-76"></a> <span class="c1"># Use the global step to match system logging behavior during train, but fall back to batch_idx for eval/test</span> </span><span id="__span-0-77"><a id="__codelineno-0-77" name="__codelineno-0-77"></a> <span class="n">current_step</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">global_step</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">mode</span> <span class="o">==</span> <span class="s1">'train'</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">batch_idx</span> </span><span id="__span-0-78"><a id="__codelineno-0-78" name="__codelineno-0-78"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span><span class="o">.</span><span class="n">freq</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span><span class="o">.</span><span class="n">is_step</span> <span class="ow">and</span> <span class="n">current_step</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span><span class="o">.</span><span class="n">freq</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> </span><span id="__span-0-79"><a id="__codelineno-0-79" name="__codelineno-0-79"></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">col</span><span class="o">.</span><span class="n">make_image</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">batch_limit</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">batch_limit</span><span class="p">)</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_columns</span><span class="p">]</span> </span><span id="__span-0-80"><a id="__codelineno-0-80" name="__codelineno-0-80"></a> <span class="n">display</span> <span class="o">=</span> <span class="n">GridDisplayF</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span> </span><span id="__span-0-81"><a id="__codelineno-0-81" name="__codelineno-0-81"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> </span><span id="__span-0-82"><a id="__codelineno-0-82" name="__codelineno-0-82"></a> <span class="n">display</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </span><span id="__span-0-83"><a id="__codelineno-0-83" name="__codelineno-0-83"></a> <span class="k">else</span><span class="p">:</span> </span><span id="__span-0-84"><a id="__codelineno-0-84" name="__codelineno-0-84"></a> <span class="n">filename</span> <span class="o">=</span> <span class="sa">f</span><span class="s1">'</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">mode</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">epoch_idx</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">batch_idx</span><span class="si">}</span><span class="s1">.html'</span> </span><span id="__span-0-85"><a id="__codelineno-0-85" name="__codelineno-0-85"></a> <span class="n">display</span><span class="o">.</span><span class="n">show</span><span class="p">(</span><span class="n">save_path</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span><span class="p">,</span> <span class="n">filename</span><span class="p">))</span> </span><span id="__span-0-86"><a id="__codelineno-0-86" name="__codelineno-0-86"></a> </span><span id="__span-0-87"><a id="__codelineno-0-87" name="__codelineno-0-87"></a> <span class="k">def</span> <span class="nf">on_epoch_end</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">:</span> <span class="n">Data</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> </span><span id="__span-0-88"><a id="__codelineno-0-88" name="__codelineno-0-88"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span><span class="o">.</span><span class="n">freq</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span><span class="o">.</span><span class="n">is_step</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">epoch_idx</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">frequency</span><span class="o">.</span><span class="n">freq</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> </span><span id="__span-0-89"><a id="__codelineno-0-89" name="__codelineno-0-89"></a> <span class="n">columns</span> <span class="o">=</span> <span class="p">[</span><span class="n">col</span><span class="o">.</span><span class="n">make_image</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">batch_limit</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">batch_limit</span><span class="p">)</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_columns</span><span class="p">]</span> </span><span id="__span-0-90"><a id="__codelineno-0-90" name="__codelineno-0-90"></a> <span class="n">display</span> <span class="o">=</span> <span class="n">GridDisplayF</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="n">columns</span><span class="p">)</span> </span><span id="__span-0-91"><a id="__codelineno-0-91" name="__codelineno-0-91"></a> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span> </span><span id="__span-0-92"><a id="__codelineno-0-92" name="__codelineno-0-92"></a> <span class="n">display</span><span class="o">.</span><span class="n">show</span><span class="p">()</span> </span><span id="__span-0-93"><a id="__codelineno-0-93" name="__codelineno-0-93"></a> <span class="k">else</span><span class="p">:</span> </span><span id="__span-0-94"><a id="__codelineno-0-94" name="__codelineno-0-94"></a> <span class="n">filename</span> <span class="o">=</span> <span class="sa">f</span><span class="s1">'</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">mode</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">epoch_idx</span><span class="si">}</span><span class="s1">_</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">batch_idx</span><span class="si">}</span><span class="s1">.html'</span> </span><span id="__span-0-95"><a id="__codelineno-0-95" name="__codelineno-0-95"></a> <span class="n">display</span><span class="o">.</span><span class="n">show</span><span class="p">(</span><span class="n">save_path</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">save_dir</span><span class="p">,</span> <span class="n">filename</span><span class="p">))</span> </span></code></pre></div></td></tr></table></div> </details> <div class="doc doc-children"> </div> </div> </div> </div> </div> </div> </article> </div> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type="button" class="md-top md-icon" data-md-component="top" hidden> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12Z"/></svg> Back to top </button> </main> <footer class="md-footer"> <nav class="md-footer__inner md-grid" aria-label="Footer" > <a href="csv_logger.html" class="md-footer__link md-footer__link--prev" aria-label="Previous: csv_logger"> <div class="md-footer__button md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg> </div> <div class="md-footer__title"> <span class="md-footer__direction"> Previous </span> <div class="md-ellipsis"> csv_logger </div> </div> </a> <a href="image_saver.html" class="md-footer__link md-footer__link--next" aria-label="Next: image_saver"> <div class="md-footer__title"> <span class="md-footer__direction"> Next </span> <div class="md-ellipsis"> image_saver </div> </div> <div class="md-footer__button md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg> </div> </a> </nav> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class="md-copyright"> </div> <div class="md-social"> <a href="https://github.com/fastestimator/fastestimator" target="_blank" rel="noopener" title="github.com" class="md-social__link"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg> </a> <a href="https://hub.docker.com/r/fastestimator/fastestimator" target="_blank" rel="noopener" title="hub.docker.com" class="md-social__link"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--! Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M349.9 236.3h-66.1v-59.4h66.1v59.4zm0-204.3h-66.1v60.7h66.1V32zm78.2 144.8H362v59.4h66.1v-59.4zm-156.3-72.1h-66.1v60.1h66.1v-60.1zm78.1 0h-66.1v60.1h66.1v-60.1zm276.8 100c-14.4-9.7-47.6-13.2-73.1-8.4-3.3-24-16.7-44.9-41.1-63.7l-14-9.3-9.3 14c-18.4 27.8-23.4 73.6-3.7 103.8-8.7 4.7-25.8 11.1-48.4 10.7H2.4c-8.7 50.8 5.8 116.8 44 162.1 37.1 43.9 92.7 66.2 165.4 66.2 157.4 0 273.9-72.5 328.4-204.2 21.4.4 67.6.1 91.3-45.2 1.5-2.5 6.6-13.2 8.5-17.1l-13.3-8.9zm-511.1-27.9h-66v59.4h66.1v-59.4zm78.1 0h-66.1v59.4h66.1v-59.4zm78.1 0h-66.1v59.4h66.1v-59.4zm-78.1-72.1h-66.1v60.1h66.1v-60.1z"/></svg> </a> </div> </div> </div> </footer> </div> <div class="md-dialog" data-md-component="dialog"> <div class="md-dialog__inner md-typeset"></div> </div> <script id="__config" type="application/json">{"base": "../../..", "features": ["content.code.copy", "content.action.view", "navigation.top", "navigation.tabs", "navigation.footer", "navigation.indexespip", "toc.follow"], "search": "../../../assets/javascripts/workers/search.f886a092.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": {"provider": "mike"}}</script> <script src="../../../assets/javascripts/bundle.d7c377c4.min.js"></script> <script src="../../../javascripts/extra.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/contrib/auto-render.min.js"></script> <script src="../../../javascripts/version-mike.js"></script> </body> </html>