小编Pra*_*aha的帖子

Keras:具有多个参数的Lambda层功能

我正在尝试Lambda在Keras中编写一个调用函数的图层,该图层connection运行一个循环for i in range(0,k),其中k作为函数的输入被输入connection(x,k).现在,当我尝试在Functional API中调用该函数时,我尝试使用:

k = 5
y = Lambda(connection)(x)
Run Code Online (Sandbox Code Playgroud)

也,

y = Lambda(connection)(x,k)
Run Code Online (Sandbox Code Playgroud)

但这些方法都没有奏效.如何在k不将其指定为全局参数的情况下输入值?

python neural-network keras keras-layer

10
推荐指数
2
解决办法
7614
查看次数

Keras:模型中可训练参数的数量

trainable=False在我的所有图层中设置,通过ModelAPI 实现,但我想验证它是否有效.model.count_params()返回参数的总数,但除了查看最后几行之外,还有什么方法可以获得可训练参数的总数model.summary()

python keras

10
推荐指数
2
解决办法
5375
查看次数

Keras:Vgg16——“decode_predictions”错误

我正在尝试使用 Keras 中预训练的 VGG16 模型执行图像分类任务。我按照Keras 应用程序页面中的说明编写的代码是:

from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input, decode_predictions
import numpy as np

model = VGG16(weights='imagenet', include_top=True)
img_path = './train/cat.1.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

features = model.predict(x)
(inID, label) = decode_predictions(features)[0]
Run Code Online (Sandbox Code Playgroud)

这与论坛中已经提出的这个问题中显示的代码非常相似。但尽管include_top参数为True,我收到以下错误:

Traceback (most recent call last):
  File "vgg16-keras-classifier.py", line 14, in <module>
    (inID, label) = decode_predictions(features)[0]
ValueError: too many values …
Run Code Online (Sandbox Code Playgroud)

classification python-2.7 conv-neural-network keras

5
推荐指数
1
解决办法
3782
查看次数

Keras的Hopfield网络

是否可以通过Keras甚至TensorFlow实现Hopfield网络?喜欢的东西newhopMATLAB

keras tensorflow recurrent-neural-network

5
推荐指数
1
解决办法
2525
查看次数