我们可以用tebnsorflow训练张量的特定部分吗?

时间:2019-10-03 16:31:43

标签: tensorflow tensor adversarial-machines

我正在尝试使用张量流为inceptionV3模型制作对抗图像。为此,我在输入图像的像素上使用特定的损失。效果很好

model_input_layer = model.layers[0].input
model_output_layer = model.layers[-1].output

cost_function = model_output_layer[0, object_type_to_fake]
gradient_function = K.gradients(cost_function, model_input_layer)[0]
grab_cost_and_gradients_from_model = K.function([model_input_layer, K.learning_phase()], [cost_function, gradient_function])

现在,我只想训练某些像素,以在某个正方形而不是在所有输入图像上创建补丁。 我尝试使用variable = tf.slice(model_input_layer, [0, 100, 100, 0], [-1, 100, 100, -1]),但是它不起作用。 有没有人做过这个?

0 个答案:

没有答案