keras:连接两个图像作为输入(DeepVO)

问题描述 投票:2回答:1

我正在尝试实现this paper中描述的模型。 我遇到问题的一个项目是设置输入,这应该是两个图像堆叠,这意味着,我有一组连续的(i & i+1)图像2048x2048x1(单色),所以输入张量将是2048x2048x2,但每个连续输入到神经网络将是以下一组图像(i+1 & i+2)。到目前为止我有

import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Concatenate, Activation, Conv2D, MaxPooling2D, Flatten, Input
from keras.klayers import Embedding,LSTM 

inp1 = Input((2048,2048,1))
inp2 = Input((2048,2048,1))
deepVO = Sequential()
deepVO.add(Concatenate(inp1,inp2,-1))
deepVO.add(Conv2D(64,(2,2)))
deepVO.add(Activation('relu'))
#....continue to add other layers

我在deepVO_CNN.add(Concatenate(inp1,inp2,-1))得到的错误是:

TypeError:__ init __()取1到2个位置参数,但给出4个。

tensorflow deep-learning keras conv-neural-network opticalflow
1个回答
3
投票

尝试像这样的keras api模式:

import numpy as np
from keras.models import Sequential
from keras.layers import Dense, Activation, Conv2D, MaxPooling2D, Flatten, Input, concatenate

from keras.models import Model

inp1 = Input((2048,2048,1))
inp2 = Input((2048,2048,1))

deepVO = concatenate([inp1, inp2],axis=-1)
deepVO = Conv2D(64,(2,2))(deepVO)
deepVO = Activation('relu')(deepVO)
...

...
outputs = Dense(num_classes, activation='softmax')(deepVO)
deepVO = Model([inp1, inp2], outputs)
#deepVO.summary()
© www.soinside.com 2019 - 2024. All rights reserved.