lstm

Keras LSTM - feed sequence data with Tensorflow dataset API from the generator

♀尐吖头ヾ 提交于 2019-12-09 23:47:51
问题 I am trying to solve how I can feed data to my LSTM model for training. (I will simplify the problem in my example below.) I have the following data format in csv files in my dataset. Timestep Feature1 Feature2 Feature3 Feature4 Output 1 1 2 3 4 a 2 5 6 7 8 b 3 9 10 11 12 c 4 13 14 15 16 d 5 17 18 19 20 e 6 21 22 23 24 f 7 25 26 27 28 g 8 29 30 31 32 h 9 33 34 35 36 i 10 37 38 39 40 j The task is to estimate the Output of any future timestep based on the data from last 3 timesteps. Some input

Varying sequence length in Keras without padding

淺唱寂寞╮ 提交于 2019-12-09 16:37:55
问题 I have a question regarding varying sequence lengths for LSTMs in Keras. I'm passing batches of size 200 and sequences of variable lengths (= x) with 100 features for each object in the sequence (=> [200, x, 100]) into a LSTM: LSTM(100, return_sequences=True, stateful=True, input_shape=(None, 100), batch_input_shape=(200, None, 100)) I'm fitting the model on the following randomly created matrices: x_train = np.random.random((1000, 50, 100)) x_train_2 = np.random.random((1000, 10,100)) As far

历史最全量化交易书籍、视频教程、博客、代码、算法整理

谁都会走 提交于 2019-12-09 15:58:15
作者:lqfarmer 来源:知乎 金融机器学习 经典书籍 · ⭐️ Marcos López de Prado - Advances in Financial Machine Learning .. · ⭐️ Dr Howard B Bandy - Quantitative Technical Analysis: An integrated approach to trading system development and trading management . · Tony Guida - Big Data and Machine Learning in Quantitative Investment . · ⭐️ Michael Halls-Moore - Advanced Algorithmic Trading . · Jannes Klaas - Machine Learning for Finance: Data algorithms for the markets and deep learning from the ground up for financial experts and economics . · Stefan Jansen - Hands-On Machine Learning for Algorithmic Trading: Design

BiLSTM+CRF(二)命名实体识别

萝らか妹 提交于 2019-12-09 13:18:37
前言 前一篇博客【https://blog.csdn.net/jmh1996/article/details/83476061 BiLSTM+CRF (一)双向RNN 浅谈 】里面,我们已经提到了如何构建一个双向的LSTM网络,并在原来单层的RNN的基础上,修改少数几行代码即可实现。 Bi-LSTM其实就是两个LSTM,只不过反向的LSTM是把输入的数据先reverse 首尾转置一下,然后跑一个正常的LSTM,然后再把输出结果reverse一次使得与正向的LSTM的输入对应起来。 这篇博客,我们就来看看如何通过BiLSTM+CRF来进行命名实体识别的任务。 先介绍一下命名实体识别任务。 命名实体识别 通俗来说,命名实体识别,就是给一句话或一段话,设计某种算法来把其中的命名实体给找出来。啥叫命名实体呢?说白了不值一提,命名实体,其实就是实际存在的具有专门名字的物体。命名实体识别,其实就是实体名字的识别。 例如: 我 们 的 藏 品 中 有 几 十 册 为 北 京 图 书 馆 等 国 家 级 藏 馆 所 未 藏 。 其中北京图书馆就是一个专有的实体名称。 一般命名实体有分:人名、地名、组织名、机构名等等之分,根据不同的任务有不同的划分。 命名实体识别的解法 目前命名实体识别领域比较流行的方法都是把命名实体识别问题转换为一个序列标注的问题,然后通过序列标注的方法来解决。

Siamese Model with LSTM network fails to train using tensorflow

 ̄綄美尐妖づ 提交于 2019-12-09 03:36:27
Dataset Description The dataset contains a set of question pairs and a label which tells if the questions are same. e.g. "How do I read and find my YouTube comments?" , "How can I see all my Youtube comments?" , "1" The goal of the model is to identify if the given question pair is same or different. Approach I have created a Siamese network to identify if two questions are same. Following is the model: graph = tf.Graph() with graph.as_default(): embedding_placeholder = tf.placeholder(tf.float32, shape=embedding_matrix.shape, name='embedding_placeholder') with tf.variable_scope('siamese

Sequence to Sequence Learning with Neural Networks(翻译)

一世执手 提交于 2019-12-08 19:26:29
Sequence to Sequence Learning with Neural Networks 摘要 本文中提出了一种通用的端到端的学习方式,对序列结构做出了做小的假设。我们的方法是使用多层LSTM将输入序列映射到固定维度的向量,然后使用另一个深层的LSTM 将这个向量解码到目标序列。LSTM还学习到合理的短语和句子的表达,即:对语序敏感而对主动语态和被动语态并不敏感。最后,我们发现翻转源句子中的单词的顺序可以明显的提高LSTM的性能,因为这样做会在源语句和目标语句之间引入许多短期相关性,从而使优化问题变得更容易。 1 简介 DNN功能强大,并且实现了卓越的性能。虽然DNN灵活且强大,但是只能应用在输入和目标可以用固定维度的向量合理的编码的问题上。这是一个严重的限制,因为许多重要的表达最好是用长度不定的序列表达。 序列对DNN构成了一个挑战,因为序列要求输入和输出的维度已知并且固定。本文中, 我们提出LSTM结构直接应用可以解决一般的序列到序列的问题。这个想法是用一个LSTM读取输入序列,一次一个时间步,去获得大的固定向量的表示,然后使用另一个输出序列在从该项量中提取出输出序列。第二个LSTM除了它取决于输入序列,其本质上就是一个RNN语言模型。LSTM可以成功在数据上学习长依赖的能力使其成为了该应用的自然选择,因为输入和相应的输出之间存在着相当的时间延迟。 注 : 图 1

基于PyTorch实现MNIST手写字识别

♀尐吖头ヾ 提交于 2019-12-08 14:24:25
本篇不涉及模型原理,只是分享下代码。想要了解模型原理的可以去看网上很多大牛的博客。 目前代码实现了CNN和LSTM两个网络,整个代码分为四部分: Config :项目中涉及的参数; CNN :卷积神经网络结构; LSTM :长短期记忆网络结构; TrainProcess : 模型训练及评估,参数 model 控制训练何种模型( CNN or LSTM )。 完整代码 — Talk is cheap, show me the code. # -*- coding: utf-8 -*- # @author: Awesome_Tang # @date: 2019-04-05 # @version: python3.7 import torch from torchvision import datasets, transforms import torch.nn as nn import torch.optim as optim from torch.autograd import Variable from datetime import datetime class Config: batch_size = 64 epoch = 10 alpha = 1e-3 print_per_step = 100 # 控制输出 class CNN(nn.Module): def __init__

Why is GeForce GTX 1080 Ti slower than Quadro K1200 on training a RNN model?

萝らか妹 提交于 2019-12-08 10:59:43
问题 Problem type : regression Inputs : sequence length varies from 14 to 39, each sequence point is a 4-element vector. Output : a scalar Neural Network : 3-layer Bi-LSTM (hidden vector size: 200) followed by 2 Fully Connected layers Batch Size : 30 Number of samples per epoch : ~7,000 TensorFlow version : tf-nightly-gpu 1.6.0-dev20180112 CUDA version : 9.0 CuDNN version : 7 Details of the two GPUs : GPU 0: name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582 totalMemory: 11

Can you manually set Tensorflow LSTM weights?

橙三吉。 提交于 2019-12-08 08:37:20
I'm exploring using recurrent neural networks to work on unsupervised problems. I would need to set the weights for each gate individually. Is there any way I can do so? Is there anything like this? LSTMCell.Weights['Forget'] = ForgetGateWeights Similar question was raised in the issues section in tensorflow. Checkout this discussion https://github.com/tensorflow/tensorflow/issues/3115 . 来源: https://stackoverflow.com/questions/42962281/can-you-manually-set-tensorflow-lstm-weights

How to setup input shape for 1dCNN+LSTM network (Keras)?

六月ゝ 毕业季﹏ 提交于 2019-12-08 07:02:27
问题 I have the following idea to implement: Input -> CNN-> LSTM -> Dense -> Output The Input has 100 time steps, each step has a 64-dimensional feature vector A Conv1D layer will extract features at each time step. The CNN layer contains 64 filters, each has length 16 taps. Then, a maxpooling layer will extract the single maximum value of each convolutional output, so a total of 64 features will be extracted at each time step. Then, the output of the CNN layer will be fed into an LSTM layer with