keras-anomaly-detection 代码分析——本质上就是SAE、LSTM时间序列预测
keras-anomaly-detection
Anomaly detection implemented in Keras
The source codes of the recurrent, convolutional and feedforward networks auto-encoders for anomaly detection can be found in keras_anomaly_detection/library/convolutional.py and keras_anomaly_detection/library/recurrent.py and keras_anomaly_detection/library/feedforward.py
The the anomaly detection is implemented using auto-encoder with convolutional, feedforward, and recurrent networks and can be applied to:
- timeseries data to detect timeseries time windows that have anomaly pattern
- LstmAutoEncoder in keras_anomaly_detection/library/recurrent.py
- Conv1DAutoEncoder in keras_anomaly_detection/library/convolutional.py
- CnnLstmAutoEncoder in keras_anomaly_detection/library/recurrent.py
- BidirectionalLstmAutoEncoder in keras_anomaly_detection/library/recurrent.py
- structured data (i.e., tabular data) to detect anomaly in data records
- Conv1DAutoEncoder in keras_anomaly_detection/library/convolutional.py
- FeedforwardAutoEncoder in keras_anomaly_detection/library/feedforward.py
看LSTM的模型吧:
def create_model(time_window_size, metric):
model = Sequential()
model.add(LSTM(units=128, input_shape=(time_window_size, 1), return_sequences=False)) model.add(Dense(units=time_window_size, activation='linear')) model.compile(optimizer='adam', loss='mean_squared_error', metrics=[metric])
print(model.summary())
return model再看feedforward的模型:
def create_model(self, input_dim):
encoding_dim = 14
input_layer = Input(shape=(input_dim,)) encoder = Dense(encoding_dim, activation="tanh",
activity_regularizer=regularizers.l1(10e-5))(input_layer)
encoder = Dense(encoding_dim // 2, activation="relu")(encoder) decoder = Dense(encoding_dim // 2, activation='tanh')(encoder)
decoder = Dense(input_dim, activation='relu')(decoder) model = Model(inputs=input_layer, outputs=decoder)
model.compile(optimizer='adam',
loss='mean_squared_error',
metrics=['accuracy'])CNN的:
def create_model(time_window_size, metric):
model = Sequential()
model.add(Conv1D(filters=256, kernel_size=5, padding='same', activation='relu',
input_shape=(time_window_size, 1)))
model.add(GlobalMaxPool1D()) model.add(Dense(units=time_window_size, activation='linear')) model.compile(optimizer='adam', loss='mean_squared_error', metrics=[metric])
print(model.summary())
return model都是将输出设置成自己,异常点就是查看偏离那90%的预测error较大的点。
keras-anomaly-detection 代码分析——本质上就是SAE、LSTM时间序列预测的更多相关文章
- DQN 处理 CartPole 问题——使用强化学习,本质上是训练MLP,预测每一个动作的得分
代码: # -*- coding: utf-8 -*- import random import gym import numpy as np from collections import dequ ...
- Kesci: Keras 实现 LSTM——时间序列预测
博主之前参与的一个科研项目是用 LSTM 结合 Attention 机制依据作物生长期内气象环境因素预测作物产量.本篇博客将介绍如何用 keras 深度学习的框架搭建 LSTM 模型对时间序列做预测. ...
- Social LSTM 实现代码分析
----- 2019.8.5更新 实现代码思维导图 ----- ----- 初始原文 ----- Social LSTM最早提出于文献 "Social LSTM: Human Traject ...
- C++卷积神经网络实例:tiny_cnn代码具体解释(8)——partial_connected_layer层结构类分析(上)
在之前的博文中我们已经将顶层的网络结构都介绍完毕,包括卷积层.下採样层.全连接层,在这篇博文中主要有两个任务.一是总体贯通一下卷积神经网络在对图像进行卷积处理的整个流程,二是继续我们的类分析.这次须要 ...
- 详细分析 Java 中实现多线程的方法有几种?(从本质上出发)
详细分析 Java 中实现多线程的方法有几种?(从本质上出发) 正确的说法(从本质上出发) 实现多线程的官方正确方法: 2 种. Oracle 官网的文档说明 方法小结 方法一: 实现 Runnabl ...
- Coursera 机器学习 第9章(上) Anomaly Detection 学习笔记
9 Anomaly Detection9.1 Density Estimation9.1.1 Problem Motivation异常检测(Density Estimation)是机器学习常见的应用, ...
- Eclipse插件(导出UML图,打开文件资源管理器插件,静态代码分析工具PMD,在eclipse上安装插件)
目录 能够导出UML图的Eclipse插件 打开文件资源管理器插件 Java静态代码分析工具PMD 如何在eclipse上安装插件 JProfiler性能分析工具 从更新站点安装EclEmma 能够导 ...
- Anomaly Detection for Time Series Data with Deep Learning——本质分类正常和异常的行为,对于检测异常行为,采用预测正常行为方式来做
A sample network anomaly detection project Suppose we wanted to detect network anomalies with the un ...
- leetcode 784. Letter Case Permutation——所有BFS和DFS的题目本质上都可以抽象为tree,这样方便你写代码
Given a string S, we can transform every letter individually to be lowercase or uppercase to create ...
随机推荐
- yum配合rpm查看软件包安装位置
今天安装apache,新版本要求除了apache的安装包以外,还要求先安装apr.apr-util和pcre. 开始并没有急着去下载apr的安装包,而是想看看我的操作系统中有没有安装过了这个软件,结果 ...
- 20145302张薇《课程设计》数据恢复——WinHex实践
20145302张薇<课程设计>数据恢复--WinHex实践 实践内容 使用WinHex破损一个U盘 使用WinHex通过DBR备份数据来修复已损坏U盘 实践详细步骤 1.准备一个文件格式 ...
- JAVA I/O(一)基本字节和字符IO流
最近再看I/O这一块,故作为总结记录于此.JDK1.4引入NIO后,原来的I/O方法都基于NIO进行了优化,提高了性能.I/O操作类都在java.io下,大概将近80个,大致可以分为4类: 基于字节操 ...
- Python3基础 os.path.getsize 获得文件的大小
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- assert函数用法总结【转】
本文转载自:http://blog.csdn.net/u014082714/article/details/45190505 assert宏的原型定义在<assert.h>中,其作用是如果 ...
- C语言宏定义中的#和##的作用【转】
本文转载自:http://my.oschina.net/shelllife/blog/123202 在宏定义中#和##的作用是:前者将宏定义的变量转化为字符串:后者将其前后的两个宏定义中的两个变量无缝 ...
- 日志统计|2018年蓝桥杯B组题解析第八题-fishers
标题:日志统计 小明维护着一个程序员论坛.现在他收集了一份"点赞"日志,日志共有N行.其中每一行的格式是: ts id 表示在ts时刻编号id的帖子收到一个"赞" ...
- Unity 之 图片显示的真实大小
图片放入Unity中自身的属性 在做帽子游戏的时候,看到这么一段代码 //获取保龄球的自身宽度 float ballWidth=ball.GetComponent<Renderer>(). ...
- BZOJ5142: [Usaco2017 Dec]Haybale Feast 线段树或二分答案
Description Farmer John is preparing a delicious meal for his cows! In his barn, he has NN haybales ...
- 【转载】可被路由的协议 & 路由协议 & 不可被路由的协议 的区别
原文地址:可被路由的协议 & 路由协议 & 不可被路由的协议 的区别 术语routed protocol(可被路由的协议)和routing protocol(路由协议)经常被混淆.可被 ...