我是一个尝试 LSTM 的新手。
我基本上使用 LSTM 来确定动作类型(5 种不同的动作),例如跑步、跳舞等。我的输入是每个动作 60 帧,大致可以说大约 120 个这样的视频
train_x.shape = (120,192,192,60)
其中 120 是用于训练的样本视频数量,192X192 是帧大小,60 是帧数。
train_y.shape = (120*5) [1 0 0 0 0 ..... 0 0 0 0 1] 一个热编码
我不清楚如何将 3d 参数传递给 lstm (时间戳和功能)
model.add(LSTM(100, input_shape=(train_x.shape[1],train_x.shape[2])))
model.add(Dropout(0.5))
model.add(Dense(100, activation='relu'))
model.add(Dense(len(uniquesegments), activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(train_x, train_y, epochs=100, batch_size=batch_size, verbose=1)
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
层顺序的输入 0 与层不兼容:预期 ndim=3,发现 ndim=4。收到的完整形状:(无、192、192、60)
训练数据算法
Loop through videos
Loop through each frame of a video
logic
append to array
convert to numpy array
roll …Run Code Online (Sandbox Code Playgroud) 我在尝试在数组上执行切片时遇到了困难,我有一个名为注释的集合,每个文档都有一个数组字段,我想访问它并应用切片以进行分页,请帮助!尝试过monk但mongodb没有效果
例子:
{
_id:xyz,
msgs:[{.....},{.....},{.....}]
}
database.collection("comments")
.find({"_id": id},{ "msgs": { "$slice": [2,5] } })
.toArray( function(err, result){
//implementation
});
Run Code Online (Sandbox Code Playgroud)