<p dir="auto">I am working on an implementation of group convolutions in Keras, after <a href="https://arxiv.org/abs/1602.07576" rel="nofollow">Cohen &amp; Welling 2016</a>. For 2D group-convolutions I've subclassed <code class="notranslate">Conv2D</code> as <code class="notranslate">GroupConv2D</code>, now I want to add 3D group-convolutions, and it makes more sense to subclass <code class="notranslate">Conv</code> as <code class="notranslate">GroupConv</code>, and then subclass that as <code class="notranslate">GroupConv2D</code> and <code class="notranslate">GroupConv3D</code>, as is done with regular convolutions in Keras. However <code class="notranslate">Conv</code> itself is not exported so I can't do that.</p>
<p dir="auto">Is it possible to make <code class="notranslate">Conv</code> public? Or is there perhaps a different way for me to do this without <code class="notranslate">Conv</code> being public? Without using the tensorflow backend I can import it (<code class="notranslate">from keras.layers.convolutional import Conv</code> works but <code class="notranslate">from tensorflow.keras.layers.convolutional import Conv</code> does not), but that seems like a bad idea, or is that fine?</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="...
qa_model=Model(input=[question_input, answer_input], output=[similarity_value])
good_output = qa_model([question_input, good_answers])
bad_output = qa_model([question_input, bad_answers])
mergedoutput = merge([good_output, bad_output],mode='concat')
training_model = Model(input=[question_input, good_answer_input, bad_answer_input], output=mergedoutput)
training_model.compile(loss=lambda y_true, y_pred: y_pred, optimizer='adam')
pred=training_model.predict([questions,good_answers,bad_answers])"><pre class="notranslate">...
<span class="pl-s1">qa_model</span><span class="pl-c1">=</span><span class="pl-v">Model</span>(<span class="pl-s1">input</span><span class="pl-c1">=</span>[<span class="pl-s1">question_input</span>, <span class="pl-s1">answer_input</span>], <span class="pl-s1">output</span><span class="pl-c1">=</span>[<span class="pl-s1">similarity_value</span>])
<span class="pl-s1">good_output</span> <span class="pl-c1">=</span> <span class="pl-en">qa_model</span>([<span class="pl-s1">question_input</span>, <span class="pl-s1">good_answers</span>])
<span class="pl-s1">bad_output</span> <span class="pl-c1">=</span> <span class="pl-en">qa_model</span>([<span class="pl-s1">question_input</span>, <span class="pl-s1">bad_answers</span>])
<span class="pl-s1">mergedoutput</span> <span class="pl-c1">=</span> <span class="pl-en">merge</span>([<span class="pl-s1">good_output</span>, <span class="pl-s1">bad_output</span>],<span class="pl-s1">mode</span><span class="pl-c1">=</span><span class="pl-s">'concat'</span>)
<span class="pl-s1">training_model</span> <span class="pl-c1">=</span> <span class="pl-v">Model</span>(<span class="pl-s1">input</span><span class="pl-c1">=</span>[<span class="pl-s1">question_input</span>, <span class="pl-s1">good_answer_input</span>, <span class="pl-s1">bad_answer_input</span>], <span class="pl-s1">output</span><span class="pl-c1">=</span><span class="pl-s1">mergedoutput</span>)
<span class="pl-s1">training_model</span>.<span class="pl-en">compile</span>(<span class="pl-s1">loss</span><span class="pl-c1">=</span><span class="pl-k">lambda</span> <span class="pl-s1">y_true</span>, <span class="pl-s1">y_pred</span>: <span class="pl-s1">y_pred</span>, <span class="pl-s1">optimizer</span><span class="pl-c1">=</span><span class="pl-s">'adam'</span>)
<span class="pl-s1">pred</span><span class="pl-c1">=</span><span class="pl-s1">training_model</span>.<span class="pl-en">predict</span>([<span class="pl-s1">questions</span>,<span class="pl-s1">good_answers</span>,<span class="pl-s1">bad_answers</span>])</pre></div>
<p dir="auto">It is OK, when i test qa_model alone</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="qa_model.compile(loss=lambda y_true, y_pred: y_pred, optimizer='adam')
pred=qa_model.predict([questions,good_answers])"><pre class="notranslate"><span class="pl-s1">qa_model</span>.<span class="pl-en">compile</span>(<span class="pl-s1">loss</span><span class="pl-c1">=</span><span class="pl-k">lambda</span> <span class="pl-s1">y_true</span>, <span class="pl-s1">y_pred</span>: <span class="pl-s1">y_pred</span>, <span class="pl-s1">optimizer</span><span class="pl-c1">=</span><span class="pl-s">'adam'</span>)
<span class="pl-s1">pred</span><span class="pl-c1">=</span><span class="pl-s1">qa_model</span>.<span class="pl-en">predict</span>([<span class="pl-s1">questions</span>,<span class="pl-s1">good_answers</span>])</pre></div>
<p dir="auto">but something wrong with training_model</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  File &quot;/Users/Documents/sources/insuranceQA-master/rnn.py&quot;, line 186, in build_model
    training_model = Model(input=[question_input, good_answer_input, bad_answer_input], output=mergedoutput)
  File &quot;/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/keras/engine/topology.py&quot;, line 1571, in __init__
    'Keras tensors. Found: ' + str(x))
Exception: Output tensors to a Model must be Keras tensors. Found: Join.0"><pre class="notranslate">  <span class="pl-v">File</span> <span class="pl-s">"/Users/Documents/sources/insuranceQA-master/rnn.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">186</span>, <span class="pl-s1">in</span> <span class="pl-s1">build_model</span>
    <span class="pl-s1">training_model</span> <span class="pl-c1">=</span> <span class="pl-v">Model</span>(<span class="pl-s1">input</span><span class="pl-c1">=</span>[<span class="pl-s1">question_input</span>, <span class="pl-s1">good_answer_input</span>, <span class="pl-s1">bad_answer_input</span>], <span class="pl-s1">output</span><span class="pl-c1">=</span><span class="pl-s1">mergedoutput</span>)
  <span class="pl-v">File</span> <span class="pl-s">"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/keras/engine/topology.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1571</span>, <span class="pl-s1">in</span> <span class="pl-s1">__init__</span>
    <span class="pl-s">'Keras tensors. Found: '</span> <span class="pl-c1">+</span> <span class="pl-en">str</span>(<span class="pl-s1">x</span>))
<span class="pl-v">Exception</span>: <span class="pl-v">Output</span> <span class="pl-s1">tensors</span> <span class="pl-s1">to</span> <span class="pl-s1">a</span> <span class="pl-v">Model</span> <span class="pl-s1">must</span> <span class="pl-s1">be</span> <span class="pl-v">Keras</span> <span class="pl-s1">tensors</span>. <span class="pl-v">Found</span>: <span class="pl-v">Join</span>.<span class="pl-c1">0</span></pre></div>
<p dir="auto">the full description can be found in <a href="https://github.com/fchollet/keras/issues/2704" data-hovercard-type="issue" data-hovercard-url="/keras-team/keras/issues/2704/hovercard">This Page</a></p>