Я пытаюсь построить неконтролируемую модель глубокого обучения с использованием сверточного автоэнкодера.
Это то, что я пробовал, я начинаю с оконного анализа, а затем преобразую данные в 3 измерениях
def windowz(data, size):
start = 0
while start < len(data):
yield start, start + size
start += (size // 2)
def segment_dap(x_train,window_size):
segments = np.zeros(((len(x_train)//(window_size//2))-1,window_size,11))
i_segment = 0
i_label = 0
for (start,end) in windowz(x_train,window_size):
if(len(x_train[start:end]) == window_size):
segments[i_segment] = x_train[start:end]
i_segment+=1
return segments
X = np.loadtxt("THEdataset.txt", delimiter=" ")
train_x, test_x = train_test_split(X, test_size=0.20, random_state=42)
print(X.shape)
print(train_x.shape)
print(test_x.shape)
input_width = 2
x_train = segment_dap(train_x,input_width)
x_test = segment_dap(test_x,input_width)
print(x_train.shape)
print(x_test.shape)
def train_model():
input_layer = Input(shape=(2,11)) # adapt this if using `channels_first` image data format
x = Conv1D(filters=11,
kernel_size=2,
strides=1,
activation='relu',
padding='same')(input_layer)
x = Conv1D(filters=11,
kernel_size=2,
strides=1,
activation='relu',
padding='same')(x)
x = Conv1D(filters=11,
kernel_size=2,
strides=1,
activation='relu',
padding='same')(x)
x = Conv1D(filters=11,
kernel_size=2,
strides=1,
activation='relu',
padding='same')(x)
x = Conv1D(filters=11,
kernel_size=2,
strides=1,
activation='relu',
padding='same')(x)
x = Conv1D(filters=11,
kernel_size=2,
strides=1,
activation='relu',
padding='same')(x)
decoded = Conv1D(filters=11,
kernel_size=2,
strides=1,
activation='relu',
padding='same')(x)
autoencoder = Model(input_layer, decoded)
autoencoder.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
hist=autoencoder.fit(x_train,x_train,
epochs=5,
batch_size=128, validation_split=0.2, verbose = 2)
avg = np.mean(hist.history['acc'])
print('The Average Training Accuracy is', avg)
но точность странная, похоже, что
Эпоха 1/5 - 88 с - потеря: -1.6041e + 06 - соотв .: 0,0850 - val_loss: -1.6078e + 06 - val_acc: 0,0851