【发布时间】:2020-04-14 09:29:09
【问题描述】:
我有一个批处理生成器,它为我提供(500, 1, 12) 形状的数据(即对应于(batch size, time steps, features))。
def batch_generator(batch_size, gen_x,gen_y):
batch_features = np.zeros((batch_size,1, 12))
batch_labels = np.zeros((batch_size,9))
while True:
for i in range(batch_size):
batch_features[i] = next(gen_x)
batch_labels[i] = next(gen_y)
yield batch_features, batch_labels
def generate_X():
while True:
with open("/my_path/my_data.csv") as f:
for line in f:
currentline = line.rstrip('\n').split(",")
currentline = np.asarray(currentline)
currentline = currentline.reshape(1,1,12)
yield currentline
def generate_y():
while True:
for i in range(len(y_train)):
y= y_train[i]
yield y
然后我尝试将其输入 1D-CNN:
model = Sequential()
model.add(Conv1D(filters=100, kernel_size=1, activation='relu', input_shape=(1,12), data_format="channels_last"))
但现在我无法使用大于 1 的内核大小(即kernel_size = 1)。这可能是因为我的时间步长等于 1。
如何使用整个批量大小作为 1D-CNN 的输入并增加 kernel_size?
【问题讨论】:
标签: python machine-learning keras conv-neural-network generator