大家好,我尝试用AlexNet + LSTM建立模型,使用原始图像作为输入。
但我遇到了这样一个错误:
ValueError: Input 0 of layer lstm_5 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 43264)
我的模型代码:
model = tf.keras.models.Sequential([
# 1st conv
tf.keras.layers.Conv2D(96, (11,11),strides=(4,4), ac
我有CNN并希望将其更改为LSTM,但当我修改代码时,收到相同的错误: ValueError:输入0与图层不兼容gru_1:期望的ndim=3,找到ndim=4
我已经更改了ndim,但没有起作用。
关注我的cnn
def build_model(X,Y,nb_classes):
nb_filters = 32 # number of convolutional filters to use
pool_size = (2, 2) # size of pooling area for max pooling
kernel_size = (3, 3) # convol
我收到了来自Keras的非常混乱的错误消息。我使用以下模型,并将其传递给形状(num_examples, n, 1)的输入。
def create_model():
model = Sequential()
model.add(LSTM(64, input_shape=(n,1), return_sequences=False))
model.add(Dense(units=n, activation='linear'))
return model
我收到一条错误消息:ValueError: Error when checking target:
我正在尝试keras.layers.LSTM,下面的代码可以工作。
#!/usr/bin/python3
import tensorflow as tf
import numpy as np
from tensorflow import keras
data = np.array([1, 2, 3]).reshape((1, 3, 1))
x = keras.layers.Input(shape=(3, 1))
y = keras.layers.LSTM(10)(x)
model = keras.Model(inputs=x, outputs=y)
print (model.predi
我正在尝试实现一个带有LSTM层的去噪自动编码器。架构紧随其后。
FC layer -> FC layer -> LSTM cell -> FC layer -> FC layer.
我不能理解我的输入维度应该如何实现这个架构?
我尝试了以下代码
batch_size = 1
model = Sequential()
model.add(Dense(5, input_shape=(1,)))
model.add(Dense(10))
model.add(LSTM(32))
model.add(Dropout(0.3))
model.add(Dense(5))
model
运行笔记本时,可从以下位置获得: https://colab.research.google.com/drive/1rMYs5bQzr1ubCnsWTgJNecYwEQamXwsn 我得到以下错误: ValueError: No gradients provided for any variable: ['sequential/conv2d/kernel:0', 'sequential_1/conv2d_1/kernel:0', 'sequential_1/batch_normalization/gamma:0', 'seque
我是tensorflow的新手,我有一个问题:我能在我的conv2d中输入一个形状不是固定的输入吗?inputs.shape =(?,1568)当我训练我的神经网络时,我得到这样的信息:raise ValueError(f'Input {input_index} of layer "{layer_name}" ' ValueError: Input 0 of layer "conv2d" is incompatible with the layer: expected min_ndim=4, found ndim=2. Full shape re
def build_model(layers):
model = Sequential()
# By setting return_sequences to True we are able to stack another LSTM layer
model.add(LSTM(layers[0], input_shape=(1, 2), return_sequences=True))
model.add(LSTM(layers[0], input_shape=(1, 2),
return_sequences=False))
model
我正在尝试对数据集运行滚动回归。但是我得到了一个错误代码,指出'endog需要有ndim 1,但有ndim 2‘。
据我所知(python的新手),在给定(1763,)的y.shape的情况下,维数是1。
我试着用.ravel()和reshape()使它变得更加1-d(尽管它已经是1-d了),但我仍然得到相同的错误代码。
下面是导致错误的代码:
# Start trialing local linear regression
dataset = df.values
X = dataset[:-1,1:]
y = dataset[:-1, 0].flatten()
y.shape, X
我正在看一本关于Python的深度学习的书,来自F.Chollet。
我试着按照代码示例来做。我刚刚安装了keras,在尝试运行以下代码时,我收到了这个错误:从这个笔记本:
from keras import models
from keras import layers
network = models.Sequential()
network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,)))
network.add(layers.Dense(10, activation='softm