gpt4 book ai didi

python - 无效参数错误 : input_1_1:0 is both fed and fetched

转载 作者:行者123 更新时间:2023-12-04 15:55:51 25 4
gpt4 key购买 nike

我在 keras-vis 中使用 visualize_activation 函数:

from vis.visualization import visualize_activation, visualize_cam
from vis.utils import utils
from keras import activations

from matplotlib import pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (18, 6)

# Utility to search for layer index by name.
# Alternatively we can specify this as -1 since it corresponds to the last
# layer.
layer_idx = utils.find_layer_idx(my_model, 're_lu_3')

patches = np.expand_dims(patches,axis=3)

# This is the output node we want to maximize.
filter_idx = None
img = visualize_activation(my_model, layer_idx, filter_indices=filter_idx,
seed_input=patches[0])
plt.imshow(img[..., 0])

但是,这会引发错误:InvalidArgumentError: input_1_1:0 is both fed and fetched。

如何解决?我尝试使用 tf.identity 创建 my_model 的副本,但这没有用。

最佳答案

keras-vis 在 pip 上似乎坏了,尝试直接在 GitHub master 分支上安装:

pip uninstall vis
pip install git+https://github.com/raghakot/keras-vis.git -U

使用 pip 上的版本,MNIST 和 ResNet 示例都输出错误:InvalidArgumentError: input_1_1:0 is both fed and fetched.。更新后,它们都运行良好。

关于python - 无效参数错误 : input_1_1:0 is both fed and fetched,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51731319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com