[9bc947]: / doc / _build / html / saving-and-loading-models.html

Download this file

156 lines (117 with data), 7.9 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Saving and loading models &#8212; 0.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="shortcut icon" href="_static/icons8-beach-30.png"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="The Maui Class" href="maui.html" />
<link rel="prev" title="Filtering and Merging latent factors" href="filtering-and-merging-latent-factors.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="saving-and-loading-models">
<h1>Saving and loading models<a class="headerlink" href="#saving-and-loading-models" title="Permalink to this headline"></a></h1>
<p>Maui models may be saved to disk, so that they may be loaded again at a later time.</p>
<div class="section" id="saving-a-trained-model-to-disk">
<h2>Saving a trained model to disk<a class="headerlink" href="#saving-a-trained-model-to-disk" title="Permalink to this headline"></a></h2>
<p>Saving a model to disk involves saving two files to a target directory. These files store the model weights and the maui parameters (the arguments the maui model was instantiated with). <a class="reference internal" href="maui.html"><span class="doc">The Maui Class</span></a> implements a the save function</p>
<dl class="function">
<dt id="maui.Maui.save">
<code class="descclassname">maui.Maui.</code><code class="descname">save</code><span class="sig-paren">(</span><em>self</em>, <em>destdir</em><span class="sig-paren">)</span><a class="headerlink" href="#maui.Maui.save" title="Permalink to this definition"></a></dt>
<dd><p>Save a maui model to disk, so that it may be reloaded later using <code class="docutils literal notranslate"><span class="pre">load()</span></code></p>
<p>destdir: destination directory in which to save model files</p>
</dd></dl>
<p>The function takes one required parameter, the destination directory where the two files will be saved. It is called directly on a maui model, like</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">maui_model</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="s1">&#39;/path/to/dir&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="loading-a-model-from-disk">
<h2>Loading a model from disk<a class="headerlink" href="#loading-a-model-from-disk" title="Permalink to this headline"></a></h2>
<p>Loading a model involves instantiating a new Maui instance using the parameters that were used on the model that is saved to disk, and then populating the weights of the model to the previously trained weights. Once a model is loaded, it can be used to transform new data to the latent space, or it can be trained further. <a class="reference internal" href="maui.html"><span class="doc">The Maui Class</span></a> has a static function to load a model from disk</p>
<dl class="function">
<dt id="maui.Maui.load">
<code class="descclassname">maui.Maui.</code><code class="descname">load</code><span class="sig-paren">(</span><em>dir</em><span class="sig-paren">)</span><a class="headerlink" href="#maui.Maui.load" title="Permalink to this definition"></a></dt>
<dd><p>Load a maui model from disk, which was previously saved using <code class="docutils literal notranslate"><span class="pre">save()</span></code></p>
<p>dir: The directory from which to load the maui model</p>
<p>maui_model: a maui model that was previously saved to disk</p>
</dd></dl>
<p>It is called directly on the Maui class, like</p>
<div class="highlight-sql notranslate"><div class="highlight"><pre><span></span><span class="n">maui</span><span class="p">.</span><span class="n">Maui</span><span class="p">.</span><span class="k">load</span><span class="p">(</span><span class="s1">&#39;/path/to/dir&#39;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/hex-maui.png" alt="Logo"/>
</a></p>
<h1 class="logo"><a href="index.html"></a></h1>
<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="autoencoder-integration.html">Multi-modal Autoencoders</a></li>
<li class="toctree-l1"><a class="reference internal" href="data-normalization.html">Data and Normalization</a></li>
<li class="toctree-l1"><a class="reference internal" href="filtering-and-merging-latent-factors.html">Filtering and Merging latent factors</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Saving and loading models</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#saving-a-trained-model-to-disk">Saving a trained model to disk</a></li>
<li class="toctree-l2"><a class="reference internal" href="#loading-a-model-from-disk">Loading a model from disk</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="maui.html">The Maui Class</a></li>
<li class="toctree-l1"><a class="reference internal" href="utils.html">Maui Utilities</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
<li>Previous: <a href="filtering-and-merging-latent-factors.html" title="previous chapter">Filtering and Merging latent factors</a></li>
<li>Next: <a href="maui.html" title="next chapter">The Maui Class</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2018, Jonathan Ronen, Altuna Akalin.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.8.2</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/saving-and-loading-models.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>