I am studying Deep Learning using Deep Learning's Chainer.
In the process, I want to combine the two data, but I don't know how to do it.
Specifically,
def forward (x1, x2):
h1 = F.relu(model.l1(x1))
h2 = F.relu(model.l2(x2))
h = F.relu(model.l3(?)?))
I would like to synthesize Model 1 and Model 2 data (make a long vector with two vectors arranged vertically, such as [x1 x2]) and put them in Model 3.
The variable in the chain uses Variable, and the normal number vstack and hstack are not available.I didn't know what to do, so could you tell me?
python deep-learning chainer neural-network
Please use chain.functions.concat
.The argument axis
allows you to specify on which dimension to concat.Please refer to the sample below.
In[2]: x1 = chain.Variable(number.array([1,2], [3,4])]))
In[3]: x2 = chain.Variable(number.array([5,6],[7,8]]))
In[4]: x1.data
Out [4]:
array([1,2],
[3, 4]])
In[5]: x2.data
Out [5]:
array([5,6],
[7, 8]])
In[6]: chain.functions.concat([x1,x2],axis=1).data
Out [6]:
array([1,2,5,6],
[3, 4, 7, 8]])
© 2024 OneMinuteCode. All rights reserved.