图形断开:无法获得张量Tensor Input Keras Python的值
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了图形断开:无法获得张量Tensor Input Keras Python的值,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3524字,纯文字阅读大概需要6分钟。
内容图文
![图形断开:无法获得张量Tensor Input Keras Python的值](/upload/InfoBanner/zyjiaocheng/782/c22dde875b7e443b9624a1c1d2b6fc8e.jpg)
我有这个代码:
# Declare the layers
inp1 = Input(shape=input_shape, name="input1")
inp2 = Input(shape=input_shape, name="input2")
# 128 -> 64
conv1_inp1 = Conv2D(start_neurons * 1, 3, activation="relu", padding="same")(inp1)
conv1_inp2 = Conv2D(start_neurons * 1, 3, activation="relu", padding="same")(inp2)
conv1 = Concatenate()([conv1_inp1, conv1_inp2])
conv1 = Conv2D(start_neurons * 1, 3, activation="relu", padding="same")(conv1)
conv1 = MaxPooling2D((2, 2))(conv1)
conv1 = Dropout(0.25)(conv1)
# 64 -> 32
conv2 = Conv2D(start_neurons * 2, (3, 3), activation="relu", padding="same")(conv1)
conv2 = Conv2D(start_neurons * 2, (3, 3), activation="relu", padding="same")(conv2)
pool2 = MaxPooling2D((2, 2))(conv2)
pool2 = Dropout(0.5)(pool2)
# 32 -> 16
conv3 = Conv2D(start_neurons * 4, (3, 3), activation="relu", padding="same")(pool2)
conv3 = Conv2D(start_neurons * 4, (3, 3), activation="relu", padding="same")(conv3)
pool3 = MaxPooling2D((2, 2))(conv3)
pool3 = Dropout(0.5)(pool3)
# 16 -> 8
conv4 = Conv2D(start_neurons * 8, (3, 3), activation="relu", padding="same")(pool3)
conv4 = Conv2D(start_neurons * 8, (3, 3), activation="relu", padding="same")(conv4)
pool4 = MaxPooling2D((2, 2))(conv4)
pool4 = Dropout(0.5)(pool4)
# Middle
convm = Conv2D(start_neurons * 16, (3, 3), activation="relu", padding="same")(pool4)
convm = Conv2D(start_neurons * 16, (3, 3), activation="relu", padding="same")(convm)
# 8 -> 16
deconv4 = Conv2DTranspose(start_neurons * 8, (3, 3), strides=(2, 2), padding="same")(convm)
uconv4 = Concatenate()([deconv4, conv4])
uconv4 = Dropout(0.5)(uconv4)
uconv4 = Conv2D(start_neurons * 8, (3, 3), activation="relu", padding="same")(uconv4)
uconv4 = Conv2D(start_neurons * 8, (3, 3), activation="relu", padding="same")(uconv4)
# 16 -> 32
deconv3 = Conv2DTranspose(start_neurons * 4, (3, 3), strides=(2, 2), padding="same")(uconv4)
uconv3 = Concatenate()([deconv3, conv3])
uconv3 = Dropout(0.5)(uconv3)
uconv3 = Conv2D(start_neurons * 4, (3, 3), activation="relu", padding="same")(uconv3)
uconv3 = Conv2D(start_neurons * 4, (3, 3), activation="relu", padding="same")(uconv3)
# 32 -> 64
deconv2 = Conv2DTranspose(start_neurons * 2, (3, 3), strides=(2, 2), padding="same")(uconv3)
uconv2 = Conv2D(start_neurons * 2, (3, 3), activation="relu", padding="same")(uconv2)
uconv2 = Conv2D(start_neurons * 2, (3, 3), activation="relu", padding="same")(uconv2)
# 64 -> 128
deconv1 = Conv2DTranspose(start_neurons * 1, (3, 3), strides=(2, 2), padding="same")(uconv2)
uconv1 = Conv2D(start_neurons * 1, (3, 3), activation="relu", padding="same")(deconv1)
uconv1 = Conv2D(start_neurons * 1, (3, 3), activation="relu", padding="same")(uconv1)
uncov1 = Dropout(0.5)(uconv1)
output_layer = Conv2D(1, (1,1), padding="same", activation="sigmoid")(uconv1)
# Declare the model and add the layers
model = Model(inputs = [inp1, inp2], outputs = output_layer)
model.summary()
model.compile(optimizer='adam',loss='binary_crossentropy')
它会生成此错误:
Graph disconnected: cannot obtain value for tensor Tensor("input_28:0", shape=(?, 128, 128, 1), dtype=float32) at layer "input_28". The following previous layers were accessed without issue: []
输入具有相同的形状,在一些论坛中,他们说问题来自于输入来自2个不同来源的事实,因此打破了之前的链接.
我真的不知道如何解决这个问题.
谁能帮我?
提前致谢.
解决方法:
这是您的图表断开连接的地方(调用时未定义uconv2):
# 32 -> 64
deconv2 = Conv2DTranspose(start_neurons * 2, (3, 3), strides=(2, 2), padding="same")(uconv3)
uconv2 = Conv2D(start_neurons * 2, (3, 3), activation="relu", padding="same")(uconv2)
内容总结
以上是互联网集市为您收集整理的图形断开:无法获得张量Tensor Input Keras Python的值全部内容,希望文章能够帮你解决图形断开:无法获得张量Tensor Input Keras Python的值所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。