Keras功能API图形断开连接错误

Seanysull

下面的代码给了我一个图形断开连接错误,但是我无法弄清它来自何处,并且不确定如何进行调试。错误被抛出在最后一行decoder = Model(latentInputs, outputs, name="decoder"),我将其与修改后的工作代码进行了比较,但无济于事。

from tensorflow.keras.layers import BatchNormalization
from tensorflow.keras.layers import Conv2D
from tensorflow.keras.layers import Conv2DTranspose
from tensorflow.keras.layers import LeakyReLU
from tensorflow.keras.layers import ReLU
from tensorflow.keras.layers import Input
from tensorflow.keras.layers import GlobalAveragePooling2D
from tensorflow.keras.layers import UpSampling2D
from tensorflow.keras.layers import Flatten
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import GaussianNoise
from tensorflow.keras.layers import Flatten
from tensorflow.keras.layers import Reshape
from tensorflow.keras.layers import Add
from tensorflow.keras.models import Model
from tensorflow.keras import backend as K
import tensorflow as tf
import numpy as np

width=256
height=256
depth=3
inputShape = (height, width, depth)
chanDim = -1
filter_size = 3
latentDim = 512

# initialize the input shape to be "channels last" along with
# the channels dimension itself

inputShape = (height, width, depth)
chanDim = -1

# define the input to the encoder
inputs = Input(shape=inputShape)
x = GaussianNoise(0.2)(inputs)

x = Conv2D(128, filter_size, strides=1, padding="same")(x)

x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)
layer_1 = Conv2D(128, filter_size, strides=2, padding="same")(x)


x = BatchNormalization(axis=chanDim)(layer_1)
x = LeakyReLU(alpha=0.2)(x)
layer_2 = Conv2D(128, filter_size, strides=2, padding="same")(x)

x = BatchNormalization(axis=chanDim)(layer_2)
x = LeakyReLU(alpha=0.2)(x)
layer_3 = Conv2D(128, filter_size, strides=2, padding="same")(x)


x = BatchNormalization(axis=chanDim)(layer_3)
x = LeakyReLU(alpha=0.2)(x)
layer_4 = Conv2D(128, filter_size, strides=2, padding="same")(x)


x = BatchNormalization(axis=chanDim)(layer_4)
x = LeakyReLU(alpha=0.2)(x)
layer_5 = Conv2D(128, filter_size, strides=2, padding="same")(x)


x = BatchNormalization(axis=chanDim)(layer_5)
x = LeakyReLU(alpha=0.2)(x)
layer_6 = Conv2D(128, filter_size, strides=2, padding="same")(x)

x = BatchNormalization(axis=chanDim)(layer_6)
x = LeakyReLU(alpha=0.2)(x)
layer_7 = Conv2D(128, filter_size, strides=2, padding="same")(x)

latent = Flatten()(layer_7)
# flatten the network and then construct our latent vector
volumeSize = K.int_shape(layer_7)

# build the encoder model
encoder = Model(inputs, latent, name="encoder")
encoder.summary()   
# start building the decoder model which will accept the
# output of the encoder as its inputs
#%%
latentInputs = Input(shape=(np.prod(volumeSize[1:]),))
x = Reshape((volumeSize[1], volumeSize[2], volumeSize[3]))(latentInputs)

dec_layer_7 = Add()([x, layer_7])
x = Conv2DTranspose(128, filter_size, strides=2, padding="same")(dec_layer_7)
x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)

dec_layer_6 = Add()([x, layer_6])
x = Conv2DTranspose(128, filter_size, strides=2, padding="same")(dec_layer_6)
x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)

dec_layer_5 = Add()([x, layer_5])
x = Conv2DTranspose(128, filter_size, strides=2, padding="same")(dec_layer_5)
x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)

dec_layer_4 = Add()([x, layer_4])
x = Conv2DTranspose(128, filter_size, strides=2, padding="same")(dec_layer_4)
x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)

dec_layer_3 = Add()([x, layer_3])
x = Conv2DTranspose(128, filter_size, strides=2, padding="same")(dec_layer_3)
x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)

dec_layer_2 = Add()([x, layer_2])
x = Conv2DTranspose(128, filter_size, strides=2, padding="same")(dec_layer_2)
x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)

dec_layer_1 = Add()([x, layer_1])
x = Conv2DTranspose(128, filter_size, strides=2, padding="same")(dec_layer_1)
x = BatchNormalization(axis=chanDim)(x)
x = LeakyReLU(alpha=0.2)(x)
outputs = Conv2DTranspose(depth, filter_size, padding="same")(x)
# apply a single CONV_TRANSPOSE layer used to recover the
# original depth of the image
# =============================================================================
# outputs = ReLU(max_value=1.0)(x)
# =============================================================================

# build the decoder model
decoder = Model(latentInputs, outputs, name="decoder")

错误是:

ValueError: Graph disconnected: cannot obtain value for tensor Tensor("input_37:0", shape=(None, 256, 256, 3), dtype=float32) at layer "input_37". The following previous layers were accessed without issue: []
马克·塞里亚尼

layer_7指的是另一种模式......你必须为提供输入layer_7你的decoder解决方案可以是通过这种方式定义您的解码器

decoder = Model([latentInputs, encoder.input], outputs, name="decoder")

此处是完整示例:https : //colab.research.google.com/drive/1W8uLy49H_8UuD9DGZvtP7Md1f4ap3u6A?usp=sharing

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Keras / Tensorflow中的错误“ ValueError:图形已断开连接”

来自分类Dev

Keras Graph断开连接

来自分类Dev

在 ResNet 网络上添加层时,图形断开连接

来自分类Dev

ADONET异步执行-连接断开错误

来自分类Dev

错误:IPC通道已断开连接

来自分类Dev

记录猫错误:设备已断开连接

来自分类Dev

ADONET异步执行-连接断开错误

来自分类Dev

如何创建连接,执行和断开连接的功能

来自分类Dev

python networkx-将断开连接的图形从单个图形保存到单独的文件中

来自分类Dev

Keras Graph断开连接,嵌入了多个输入

来自分类Dev

检测到错误时推杆自动重新连接/断开连接

来自分类Dev

微调图形错误API 21

来自分类Dev

等效于某些FQL功能的图形API

来自分类Dev

等效于某些FQL功能的图形API

来自分类Dev

多个chrome.runtime.onMessage-Listeners-端口断开连接错误

来自分类Dev

连接断开时未检测到QNetworkReply错误信号

来自分类Dev

sftp收到断开连接11:应用程序错误

来自分类Dev

Hyper-v错误-视频远程连接意外断开

来自分类Dev

UiPath 错误:执行 UI 操作时桌面已断开连接

来自分类Dev

如果 ssh 断开连接,可以响应多少可能的错误消息?

来自分类Dev

SquirrelMail - 错误:IMAP 服务器断开连接

来自分类Dev

P4 python 连接断开 SSL 错误

来自分类Dev

Kubernetes API服务器断开监视连接

来自分类Dev

MySQL Api:查询期间与MySQL服务器的连接断开

来自分类Dev

在scala中出现“ {}”消息后,#slack RTM api断开连接

来自分类Dev

使用MS Graph API for Sharepoint的间歇性连接断开

来自分类Dev

如何断开Gmail API服务实例的连接?

来自分类Dev

Broadcom WICED API不会断开蓝牙LE连接

来自分类Dev

在scala中出现“ {}”消息后,#slack RTM api断开连接

Related 相关文章

  1. 1

    Keras / Tensorflow中的错误“ ValueError:图形已断开连接”

  2. 2

    Keras Graph断开连接

  3. 3

    在 ResNet 网络上添加层时,图形断开连接

  4. 4

    ADONET异步执行-连接断开错误

  5. 5

    错误:IPC通道已断开连接

  6. 6

    记录猫错误:设备已断开连接

  7. 7

    ADONET异步执行-连接断开错误

  8. 8

    如何创建连接,执行和断开连接的功能

  9. 9

    python networkx-将断开连接的图形从单个图形保存到单独的文件中

  10. 10

    Keras Graph断开连接,嵌入了多个输入

  11. 11

    检测到错误时推杆自动重新连接/断开连接

  12. 12

    微调图形错误API 21

  13. 13

    等效于某些FQL功能的图形API

  14. 14

    等效于某些FQL功能的图形API

  15. 15

    多个chrome.runtime.onMessage-Listeners-端口断开连接错误

  16. 16

    连接断开时未检测到QNetworkReply错误信号

  17. 17

    sftp收到断开连接11:应用程序错误

  18. 18

    Hyper-v错误-视频远程连接意外断开

  19. 19

    UiPath 错误:执行 UI 操作时桌面已断开连接

  20. 20

    如果 ssh 断开连接,可以响应多少可能的错误消息?

  21. 21

    SquirrelMail - 错误:IMAP 服务器断开连接

  22. 22

    P4 python 连接断开 SSL 错误

  23. 23

    Kubernetes API服务器断开监视连接

  24. 24

    MySQL Api:查询期间与MySQL服务器的连接断开

  25. 25

    在scala中出现“ {}”消息后,#slack RTM api断开连接

  26. 26

    使用MS Graph API for Sharepoint的间歇性连接断开

  27. 27

    如何断开Gmail API服务实例的连接?

  28. 28

    Broadcom WICED API不会断开蓝牙LE连接

  29. 29

    在scala中出现“ {}”消息后,#slack RTM api断开连接

热门标签

归档