<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Thu, Aug 30, 2018 at 9:41 PM Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Aug 31, 2018 at 3:19 AM, Michael Selik <span dir="ltr"><<a href="mailto:mike@selik.org" target="_blank">mike@selik.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span><div dir="ltr">On Thu, Aug 30, 2018 at 5:31 PM James Lu <<a href="mailto:jamtlu@gmail.com" target="_blank">jamtlu@gmail.com</a>> wrote:<br></div></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><span><div>It would be nice if there was a DSL for describing neural networks (Keras).</div></span><div><pre><code class="gmail-m_6332127186547785267m_-910464319473327407m_-489860487236948850gmail-python gmail-m_6332127186547785267m_-910464319473327407m_-489860487236948850gmail-hljs">model.add(Dense(units=<span class="gmail-m_6332127186547785267m_-910464319473327407m_-489860487236948850gmail-hljs-number">64</span>, activation=<span class="gmail-m_6332127186547785267m_-910464319473327407m_-489860487236948850gmail-hljs-string">'relu'</span>, input_dim=<span class="gmail-m_6332127186547785267m_-910464319473327407m_-489860487236948850gmail-hljs-number">100</span>))
model.add(Dense(units=<span class="gmail-m_6332127186547785267m_-910464319473327407m_-489860487236948850gmail-hljs-number">10</span>, activation=<span class="gmail-m_6332127186547785267m_-910464319473327407m_-489860487236948850gmail-hljs-string">'softmax'</span>))</code></pre></div></div></div></blockquote><div><br></div><div>Why not JSON or XML for cross-language compatibility?</div></div></div></blockquote><div><br></div><div>Presumably because those are even harder to read and write for humans.</div></div></div></div></blockquote><div><br></div><div>Guido is absolutely right (as usual) that JSON or XML would be *vastly* harder to read than that very clean Python code.</div><div><br></div><div>That said, if you wanted a "DSL", the perfect choice would be YAML.  The description above could look like this:</div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_quote"><div><font face="monospace, monospace">>>> model = '''</font></div><div><font face="monospace, monospace">... model:</font></div><div><font face="monospace, monospace">...   - layer: Dense</font></div><div><font face="monospace, monospace">...     units: 64</font></div><div><font face="monospace, monospace">...     activation: relu</font></div><div><font face="monospace, monospace">...     input_dim: 100</font></div><div><font face="monospace, monospace">...   - layer: Dense</font></div><div><font face="monospace, monospace">...     units: 10</font></div><div><font face="monospace, monospace">...     activation: softmax</font></div><div><font face="monospace, monospace">... '''</font></div><div><font face="monospace, monospace">>>> yaml.load(model)</font></div><div><font face="monospace, monospace">{'model': [{'layer': 'Dense', 'units': 64, 'activation': 'relu', 'input_dim': 100}, {'layer': 'Dense', 'units': 10, 'activation': 'softmax'}]}</font></div></div></blockquote><div dir="ltr"><br></div><div>This format could easily be either a string within a Python program or an external file with the definition.  YAML is already well supported in Python, all you'd need to do is write a little wrapper to translate the description above into the actual Keras API calls, which would be pretty easy.</div><div><br></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div></div></div></div>