lstm

LSTM on sequential data, predicting a discrete column

こ雲淡風輕ζ 提交于 2019-11-27 08:27:56
问题 I am new to ML and only scratching its surface so I apologize if my question makes no sense. I have a sequence of continuous measurements for some object (capturing its weight, size, temperature,...) and a discrete column determining the property of the object (a finite range of integers, say 0,1,2). This is the column that I would like to predict. The data in question is indeed a sequence since the value of the property column may vary depending on the context surrounding it and there may

What is the fastest way to prepare data for RNN with numpy?

房东的猫 提交于 2019-11-27 07:33:35
问题 I currently have a (1631160,78) np array as my input to a neural network. I would like to try something with LSTM which requires a 3D structure as input data. I'm currently using the following code to generate the 3D structure needed but it is super slow (ETA > 1day). Is there a better way to do this with numpy? My current code to generate data: def transform_for_rnn(input_x, input_y, window_size): output_x = None start_t = time.time() for i in range(len(input_x)): if i > 100 and i % 100 == 0

交通量预测——极端情况下的预测算法

青春壹個敷衍的年華 提交于 2019-11-27 07:15:39
1.背景介绍 在高方差时段(如节假日和体育赛事等等)准确的预测交通量,对于异常检测、资源分配、预算规划和其他相关的任务都是至关重要,这些任务有助于网约车大规模优化用户体验,然而,预测这些变量极具挑战性,因为这种极端事件预测取决于天气、城市人口增长和其他导致预测不确定性的外部因素。 近几年来,长短期记忆网络技术以其端到端建模,易于映入外生变量和自动特征抽取的特点,成为了一种流行的时间序列建模框架。LSTM方法利用多个维度的大量数据,可以对复杂的非线性特征相互作用进行建模,这对于预测极端事件是至关重要的。 在Lingxue Zhu和Nikolay Laptev发表在IEEE的一篇论文 Deep and Confident Prediction for Time Series at Uber 中,介绍一种新的端到端贝叶斯神经网络(BNN)结构,它能在大规模的情况下更精准地预测时间序列结果和不确定性预测。 2.概述 2.1不确定性预测 首先,我们用函数 来表示一个神经网络,其中f表示是网络的结构,用** W **来表示模型参数的集合。在BNN模型中,引入了权重参数的先验,并且模型的目标是去拟合最优的后验分布。比如,高斯先验通常假设: 。 然后,我们进一步数据生成分布定为 。在回归问题中,我们通常假设: (其中具有一定的噪声 )。 接着,给定N个观测值 和

Define custom LSTM Cell in Keras?

こ雲淡風輕ζ 提交于 2019-11-27 07:08:33
问题 I use Keras with TensorFlow as back-end. If I want to make a modification to an LSTM cell, such as "removing" the output gate, how can I do it? It is a multiplicative gate, so somehow I will have to set it to fixed values so that whatever multiplies it, has no effect. 回答1: First of all, you should define your own custom layer. If you need some intuition how to implement your own cell see LSTMCell in Keras repository. E.g. your custom cell will be: class MinimalRNNCell(keras.layers.Layer): def

Proper way to feed time-series data to stateful LSTM?

那年仲夏 提交于 2019-11-27 06:53:02
问题 Let's suppose I have a sequence of integers: 0,1,2, .. and want to predict the next integer given the last 3 integers, e.g.: [0,1,2]->5 , [3,4,5]->6 , etc Suppose I setup my model like so: batch_size=1 time_steps=3 model = Sequential() model.add(LSTM(4, batch_input_shape=(batch_size, time_steps, 1), stateful=True)) model.add(Dense(1)) It is my understanding that model has the following structure (please excuse the crude drawing): First Question: is my understanding correct? Note I have drawn

Neural Network LSTM input shape from dataframe

左心房为你撑大大i 提交于 2019-11-27 06:20:59
I am trying to implement an LSTM with Keras . I know that LSTM's in Keras require a 3D tensor with shape (nb_samples, timesteps, input_dim) as an input. However, I am not entirely sure how the input should look like in my case, as I have just one sample of T observations for each input, not multiple samples, i.e. (nb_samples=1, timesteps=T, input_dim=N) . Is it better to split each of my inputs into samples of length T/M ? T is around a few million observations for me, so how long should each sample in that case be, i.e., how would I choose M ? Also, am I right in that this tensor should look

Predicting a multiple forward time step of a time series using LSTM

独自空忆成欢 提交于 2019-11-27 05:36:13
问题 I want to predict certain values that are weekly predictable (low SNR). I need to predict the whole time series of a year formed by the weeks of the year (52 values - Figure 1) My first idea was to develop a many-to-many LSTM model (Figure 2) using Keras over TensorFlow. I'm training the model with a 52 input layer (the given time series of previous year) and 52 predicted output layer (the time series of next year). The shape of train_X is (X_examples, 52, 1), in other words, X_examples to

Keras: the difference between LSTM dropout and LSTM recurrent dropout

家住魔仙堡 提交于 2019-11-27 05:11:26
问题 From the Keras documentation: dropout: Float between 0 and 1. Fraction of the units to drop for the linear transformation of the inputs. recurrent_dropout: Float between 0 and 1. Fraction of the units to drop for the linear transformation of the recurrent state. Can anyone point to where on the image below each dropout happens? 回答1: I suggest taking a look at (the first part of) this paper. Regular dropout is applied on the inputs and/or the outputs, meaning the vertical arrows from x_t and

LSTM module for Caffe

允我心安 提交于 2019-11-27 04:32:12
Does anyone know if there exists a nice LSTM module for Caffe? I found one from a github account by russel91 but apparantly the webpage containing examples and explanations disappeared (Formerly http://apollo.deepmatter.io/ --> it now redirects only to the github page which has no examples or explanations anymore). I know Jeff Donahue worked on LSTM models using Caffe. He also gave a nice tutorial during CVPR 2015. He has a pull-request with RNN and LSTM. Update : there is a new PR by Jeff Donahue including RNN and LSTM. This PR was merged on June 2016 to master. Shai In fact, training

基于LSTM的股票涨跌分析-pytorch

巧了我就是萌 提交于 2019-11-27 03:26:18
通过输入是个指标对每天的涨跌进行相关预测,实现的准确率达到93%,加入交叉熵进行相关损失函数,尽量减小过拟合现象,但是在参数的最有参数选择的时候,并没有加入最优适应,需要后期进行相关的模型优化,代码如下 import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport torchfrom torch import nnfrom torch.autograd import Variabledata_csv = pd.read_csv('D:/Python/gs/data.csv')data_csv = data_csv.dropna(axis=0, how='any')data_csv = data_csv.valuesdata_x = data_csv[:, :10].astype('float32')data_y = data_csv[:, 10].astype('int32')data_x_normed = (data_x - np.min(data_x, axis=0)) / (np.max(data_x, axis=0)-np.min(data_x, axis=0))#data_x_normed=(data_x-np.mean(data_x,axis=0))/np.std(data_x