title: Tree-LSTM in Keras
body: <p>I would like to use a <code>tree-LSTM</code> in <a href="/questions/tagged/keras" class="post-tag" title="show questions tagged &#39;keras&#39;" rel="tag">keras</a>, similar to what is described in this article: <a href="https://arxiv.org/abs/1503.00075" rel="noreferrer">https://arxiv.org/abs/1503.00075</a>.
  It is essentially similar to a <strong>Long Short-Term Memory</strong> network, but with a tree-like input sequence instead of a chain-like one.</p>
  <p>I think it is a relatively standard architecture and would find uses in a lot of contexts, but I couldn't find any public <a href="/questions/tagged/keras" class="post-tag" title="show questions tagged &#39;keras&#39;" rel="tag">keras</a> implementation of it. Is this something that already exists somewhere?</p>
  <p>The closest I could find is this <a href="/questions/tagged/torch" class="post-tag" title="show questions tagged &#39;torch&#39;" rel="tag">torch</a> implementation: <a href="https://github.com/stanfordnlp/treelstm" rel="noreferrer">https://github.com/stanfordnlp/treelstm</a>, but that won't integrate well with the rest of my project.</p>
  <p>Question is, how can I implement <a href="https://www.sciencedirect.com/science/article/abs/pii/S0957417420310435#:%7E:text=3.2.-,Tree%20structural%20recurrent%20neural%20network%20(Tree%2DRNN),to%20implement%20network%20traffic%20classification." rel="noreferrer"><strong>Tree-RNN</strong></a> or <strong>Tree-LSTM</strong> in <a href="/questions/tagged/keras" class="post-tag" title="show questions tagged &#39;keras&#39;" rel="tag">keras</a>? FYI, it wasn't possible (AFAIK) to implement such architecture with sequential or functional API but it can be implemented in subclassed API introduced in <a href="/questions/tagged/tensorflow2" class="post-tag" title="show questions tagged &#39;tensorflow2&#39;" rel="tag">tensorflow2</a>, <a href="https://keras.io/guides/functional_api/" rel="noreferrer">source</a>.</p>