擅长:python、mysql、java
<p>是的,这在<code>keras</code>中是可能的,但它需要一些API的高级知识。特别是,您需要考虑如何计算每个输出相对于输入的损失</p>
<p>我建议检查一下<a href="https://keras.io/guides/" rel="nofollow noreferrer">developer guides</a>,也许从<a href="https://keras.io/guides/functional_api/" rel="nofollow noreferrer">functional API</a>和<a href="https://keras.io/guides/writing_a_training_loop_from_scratch/" rel="nofollow noreferrer">custom training loops</a>开始</p>
<p>下面是如何使用函数式API创建此类网络的示意图</p>
<pre class="lang-py prettyprint-override"><code>from tensorflow import keras
input_shape: int = 100
inputs = keras.Input(shape=(input_shape,))
units: int = 64
dense1 = layers.Dense(units)
dense2 = layers.Dense(units)
dense3 = layers.Dense(units)
out1 = dense1(inputs)
out2 = dense2(inputs)
out3 = dense3(inputs)
</code></pre>