gpt4 book ai didi

python - “模型”对象没有属性 'add' Keras Autoencoder

转载 作者:太空宇宙 更新时间:2023-11-03 15:30:04 25 4
gpt4 key购买 nike

我想向我的自动编码器添加初始化程序

autoencoder=Model(input_img, decoded)
autoencoder.add(Dense(64,kernel_initializer='random_uniform',
bias_initializer='zeros'))

但我收到此错误

'Model' object has no attribute 'add'

最佳答案

如果您想顺序添加层(使用 .add() 方法),则需要使用 Sequential() 模型,如下所示:

autoencoder = Sequential()
autoencoder.add(Dense(64,kernel_initializer='random_uniform',
bias_initializer='zeros',input_shape=your_input_shape))

您可以通过阅读guide to Sequential model找到更完整的解释。和 its counterpart for the functional API .

关于python - “模型”对象没有属性 'add' Keras Autoencoder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42951051/

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