Код: Выделить всё
import tensorflow as tf
import tensorflow.keras.layers as klayers
import tensorflow.keras.models as kmodels
import tensorflow.keras.backend as kbackend
tf.compat.v1.disable_eager_execution()
model = ...(omitted)
neuron_indexing = klayers.Input(
shape=(2,), # infer amount of output neurons
dtype=np.int32,
name="neuron_indexing",
)
analysis_inputs = [neuron_indexing]
inputs = model.inputs + analysis_inputs
outputlist = model.outputs + [neuron_indexing]
X, index = outputlist
model_output = tf.gather_nd(X, index)
tmpmodel = kmodels.Model(inputs=inputs, outputs=model_output)
analysis_outputs = kbackend.gradients(tmpmodel.outputs[0], model.inputs)
outputs = analysis_outputs
analyzer_model = kmodels.Model(inputs=inputs,outputs=outputs)
Код: Выделить всё
InvalidArgumentError: 2 root error(s) found.
(0) INVALID_ARGUMENT: You must feed a value for placeholder tensor 'conv2d_input' with dtype float and shape [?,50,50,1]
[[{{node conv2d_input}}]]
[[gradients/zeros/Const/_265]]
(1) INVALID_ARGUMENT: You must feed a value for placeholder tensor 'conv2d_input' with dtype float and shape [?,50,50,1]
[[{{node conv2d_input}}]]
0 successful operations.
0 derived errors ignored.
Я пытался переключить версию, также пробовал с tf.gradients и tf.GradientTape(), первый выдает ту же ошибку, а второй — другие ошибки.
Подробнее здесь: https://stackoverflow.com/questions/787 ... d-input-wi