lstm

Confused about how to implement time-distributed LSTM + LSTM

时光怂恿深爱的人放手 提交于 2019-12-11 01:27:49
问题 After much reading and diagramming, I think I've come up with a model that I can use to as the foundation for more testing on which parameters and features I need to tweak. However, I am confused about how to implement the following test case (all numbers are orders of magnitude smaller than final model, but I want to start small): Input data: 5000x1 time series vector, split into 5 epochs of 1000x1 For each time step, 3 epochs worth of data will be put through 3 time-distributed copies of a

Tensorflow - ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type float)

戏子无情 提交于 2019-12-11 01:26:02
问题 Continuation from previous question: Tensorflow - TypeError: 'int' object is not iterable My training data is a list of lists each comprised of 1000 floats. For example, x_train[0] = [0.0, 0.0, 0.1, 0.25, 0.5, ...] Here is my model: model = Sequential() model.add(LSTM(128, activation='relu', input_shape=(1000, 1), return_sequences=True)) model.add(Dropout(0.2)) model.add(LSTM(128, activation='relu')) model.add(Dropout(0.2)) model.add(Dense(32, activation='relu')) model.add(Dropout(0.2)) model

OCR目标识别

半城伤御伤魂 提交于 2019-12-11 00:37:20
先抱怨一句,识别真的比检测难很多呀,文字识别可根据待识别的文字特点采用不同的识别方法,一般分为定长文字、不定长文字两大类别。 定长文字: 定长字符识别中比较广泛的几个例子就是:MNIST识别,验证码识别,车牌识别。 MNIST: MNIST这个感觉实在是没啥说的,拿出一本深度学习入门书籍,可能实战篇就有这个项目,无论什么深度学习框架上网搜,都能搜出一大堆程序。 验证码识别: 验证码这一块,现成的代码也比较多了,文章这一块我参考了 https://my.oschina.net/u/876354/blog/3048523 ,代码这一块我参考了 https://github.com/nickliqian/cnn_captcha 。 车牌识别: 无,虽然现在车牌识别的产品已经很多了,但是网上基本没有开源的项目。我试过搜索一些论文和博客,感觉很多都是让你测效果,如何做出来的,网络结构这一块,没有找到,打开就是我做的车牌多准多准这样。 不定长文字识别: 不定长文字识别是目前OCR识别研究方向的主流,一些论文啥的也比较多,我做的不是这个方向,所以只是简单浏览了一下,看看有没有什么能用的,并没有深入调研,如果研究这个方向的可以参考这篇总结: https://github.com/hwalsuklee/awesome-deep-text-detection-recognition

ValueError: Error when checking target: expected lstm_27 to have 2 dimensions, but got array with shape (1, 11, 1)

冷暖自知 提交于 2019-12-11 00:16:05
问题 I am trying to incorporate a simple LSTM autoencoder mentioned in the keras.io website with a sequence input. It is throwing an error at the LSTM layer input. from keras.layers import Input, LSTM, RepeatVector from keras.models import Model import numpy as np def autoencoder(timesteps,input_dim): inputs = Input(shape=(timesteps, input_dim)) encoded = LSTM(300)(inputs) decoded = RepeatVector(timesteps)(encoded) decoded = LSTM(input_dim, return_sequences=True)(decoded) encoder = Model(inputs,

Retrieving last value of LSTM sequence in Tensorflow

三世轮回 提交于 2019-12-10 23:43:28
问题 I have sequences of different lengths that I want to classify using LSTMs in Tensorflow. For the classification I just need the LSTM output of the last timestep of each sequence. max_length = 10 n_dims = 2 layer_units = 5 input = tf.placeholder(tf.float32, [None, max_length, n_dims]) lengths = tf.placeholder(tf.int32, [None]) cell = tf.nn.rnn_cell.LSTMCell(num_units=layer_units, state_is_tuple=True) sequence_outputs, last_states = tf.nn.dynamic_rnn(cell, sequence_length=lengths, inputs=input)

Tensorflow basic_rnn_seq2seq TypeError: Expected int32, got -0.1 of type 'float' instead

邮差的信 提交于 2019-12-10 18:48:38
问题 I am trying to run the encoder-decoder model on the dataset. Below is the sample code: self._input_data = tf.placeholder(tf.int32, [batch_size, num_steps]) self._targets = tf.placeholder(tf.int32, [batch_size, num_steps]) enc_inputs.append(self._input_data) #one batch at once dec_inputs.append(self._targets) model = seq2seq.basic_rnn_seq2seq(enc_inputs, dec_inputs, tf.nn.rnn_cell.BasicLSTMCell(size, state_is_tuple=True)) I get an error of type mismatch (mentioned below). Does anyone know to

tensorflow: shared variables error with simple LSTM network

不想你离开。 提交于 2019-12-10 18:29:07
问题 I am trying to build a simplest possible LSTM network. Just want it to predict the next value in the sequence np_input_data . import tensorflow as tf from tensorflow.python.ops import rnn_cell import numpy as np num_steps = 3 num_units = 1 np_input_data = [np.array([[1.],[2.]]), np.array([[2.],[3.]]), np.array([[3.],[4.]])] batch_size = 2 graph = tf.Graph() with graph.as_default(): tf_inputs = [tf.placeholder(tf.float32, [batch_size, 1]) for _ in range(num_steps)] lstm = rnn_cell

Use pre-trained word2vec in lstm language model?

北城余情 提交于 2019-12-10 18:26:36
问题 I used tensorflow to train LSTM language model, code is from here. According to article here, it seems that if I use pre-trained word2vec, it works better. Using word embeddings such as word2vec and GloVe is a popular method to improve the accuracy of your model. Instead of using one-hot vectors to represent our words, the low-dimensional vectors learned using word2vec or GloVe carry semantic meaning – similar words have similar vectors. Using these vectors is a form of pre-training. So, I

How can i reshape my data for keras lstm input?

烈酒焚心 提交于 2019-12-10 17:35:56
问题 I'm new to Keras, and I find it hard to understand the shape of input data of the LSTM layer. The Keras Document says that the input data should be 3D tensor with shape (nb_samples, timesteps, input_dim). I have 808 signals. And each signal has 22 channel and 2000 data points. Data_shape : (808,22,2000) Also i have 808 labels for each signal. Label_shape : (808,2) Label[1,:] = [1,0] I want to analyze with slice 2000 data points into 20 time steps, and each time steps(lstm cell) receive 100

TypeError when trying to create a BLSTM network in Keras

早过忘川 提交于 2019-12-10 16:44:49
问题 I'm a bit new to Keras and deep learning. I'm currently trying to replicate this paper but when I'm compiling the second model (with the LSTMs) I get the following error: "TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'" The description of the model is this: Input (length T is appliance specific window size) Parallel 1D convolution with filter size 3, 5, and 7 respectively, stride=1 , number of filters=32 , activation type=linear , border mode=same Merge layer which