首页 > 解决方案 > 如何为 Tensorflow 自动编码器准备数据(多个“时间序列”)

问题描述

我正在使用 Tensorflow 自动编码器从生产数据中检测异常。

我有一个包含 1927 个元素的列表。每个元素代表一个形状为 6000,20 的 numpy 数组。(来自 19 个特征的 6000 个 count_timersiere - 代表一个生产零件)

all_data = []
for df in yp_clean:
    batch_sample = np.asarray(df)
    for sample in batch_sample:
        all_data.append(sample)
all_data = np.asarray(all_data)
inp = tf.keras.layers.Input(shape = (20, ))

x = tf.keras.layers.Dense(128, activation='relu')(inp)
x = tf.keras.layers.Dense(64, activation='relu')(x)
enc = tf.keras.layers.Dense(2, activation='relu', name='enc')(x)

x = tf.keras.layers.Dense(64, activation='relu')(enc)
x = tf.keras.layers.Dense(128, activation='relu')(x)
out = tf.keras.layers.Dense(20, activation='relu')(x)

autoencoder = tf.keras.models.Model(inp, out)
autoencoder.summary()

count_timeseries 从 1 开始到 6000,表示 30 秒的时间段

数据

我的方法是将所有数据堆叠到一个 hugh np.array 中。形状 1927*6000,20 至少我能够运行自动编码器。但我担心我丢失了“time_series”信息。

我的恐惧正确吗?有没有人做过类似的事情?

顺便说一句:所以我只有 ok 部分的数据,下一步是添加 nok。但我需要知道如何提前准备数据。

感谢您的帮助!

标签: pythontensorflow

解决方案


推荐阅读