TD 단계;
features
.8, .1, .3
.2, .4, .6
.7, .2, .1
하려면 :
[[.8
.1
.3],
[.2,
.4,
.6
],
[.3,
.6
.1]]
기본적으로 다음과 같습니다 데이터 집합을 재편 X = np.expand_dims(X, axis=2) # reshape (569, 30) to (569, 30, 1)
# now input can be set as
model.add(Conv1D(2,2,activation='relu',input_shape=(30, 1))
: Conv1d
가 이해하는 LR 당신은 공간 차원이 당신에게 데이터를 바꿀 필요
설명 및 예
일반적으로 컨볼 루션은 공간 차원에서 작동합니다. 커널은 텐서를 생성하는 차원에서 "컨볼 루션 (convolved)"합니다. Conv1D의 경우, 커널은 모든 예제의 'steps'차원으로 전달됩니다.
steps
은 문장의 단어 수 (고정 된 최대 길이로 채워짐) 인 NLP에서 Conv1D가 사용 된 것을 볼 수 있습니다.
jack .1 .3 -.52 |
is .05 .8, -.7 |<--- kernel is `convolving` along this dimension.
a .5 .31 -.2 |
boy .5 .8 -.4 \|/
그리고 우리는이 경우 전환에 대한 입력으로 설정하는 방법과 :
maxlen = 4
input_dim = 3
model.add(Conv1D(2,2,activation='relu',input_shape=(maxlen, input_dim))
을 단어가 여기에
길이 4의 벡터로 인코딩 할 수있는 것이라고하는 것은 예를 들어 문장이다
귀하의 경우에는 길이가 1 인 각 피처의 공간 치수로 피처를 처리합니다. (아래 참조)
여기에 데이터 세트
01의 예제가 있습니다. 23,516,
att1 .04 |
att2 .05 | < -- kernel convolving along this dimension
att3 .1 | notice the features have length 1. each
att4 .5 \|/ example have these 4 featues.
그리고 우리는 Conv1D의 모범을 것 같은 :
maxlen = num_features = 4 # this would be 30 in your case
input_dim = 1 # since this is the length of _each_ feature (as shown above)
model.add(Conv1D(2,2,activation='relu',input_shape=(maxlen, input_dim))
당신은 당신의 데이터 세트가로 재편되어야한다시피 (569, 30, 1) 사용 :
X = np.expand_dims(X, axis=2) # reshape (569, 30, 1)
# now input can be set as
model.add(Conv1D(2,2,activation='relu',input_shape=(30, 1))
실행할 수있는 완전한 깃발 예제가 있습니다 (Functional API를 사용합니다)
from keras.models import Model
from keras.layers import Conv1D, Dense, MaxPool1D, Flatten, Input
import numpy as np
inp = Input(shape=(5, 1))
conv = Conv1D(filters=2, kernel_size=2)(inp)
pool = MaxPool1D(pool_size=2)(conv)
flat = Flatten()(pool)
dense = Dense(1)(flat)
model = Model(inp, dense)
model.compile(loss='mse', optimizer='adam')
print(model.summary())
# get some data
X = np.expand_dims(np.random.randn(10, 5), axis=2)
y = np.random.randn(10, 1)
# fit model
model.fit(X, y)
이고 치수가 1x690 인 데이터는 커널 크기가 3 인 40 개의 필터가있는 Conv1D 레이어를 보면 레이어의 가중치를 보면 40 * 690 * 3의 가중치가 있다고합니다. 나는 이것이 왜인지 이해할 수 없다. 나는 40 * 3의 가중치 만 가질 것이라고 생각했다. 1x40 모양을 어떻게 출력합니까? – jerpint