lstm

Tensorflow value error when chaining content of data - Cannot feed value of shape (1, 1) for Tensor 'Placeholder_1:0',

走远了吗. 提交于 2020-01-06 04:53:12
问题 This post is related to the following question. The code above is taken from the accepted answer. The program itself works fine as is, but if I only changed the values of the data provided from df = pd.DataFrame({'Temperature': [183, 10.7, 24.3, 10.7], 'Weight': [8, 11.2, 14, 11.2], 'Size': [3.97, 7.88, 11, 7.88], 'Property': [0,1,2,0]}) to df = pd.DataFrame({'Temperature': [0,0,0,0], 'Weight': [1,2,3,4], 'Size': [1,2,3,4], 'Property': [1,1,1,1]}) I receive the following error while executing

How to deal with triplet loss when at time of input i have only two files i.e. at time of testing

拜拜、爱过 提交于 2020-01-06 04:41:05
问题 I am implementing a siamese network in which i know how to calculate triplet loss by picking anchor, positive and negative by dividing input in three parts(which is a handcrafted feature vector) and then calculating it at time of training. anchor_output = ... # shape [None, 128] positive_output = ... # shape [None, 128] negative_output = ... # shape [None, 128] d_pos = tf.reduce_sum(tf.square(anchor_output - positive_output), 1) d_neg = tf.reduce_sum(tf.square(anchor_output - negative_output)

Top k categorical accuracy for Time Distributed LSTM results

▼魔方 西西 提交于 2020-01-05 07:22:06
问题 I'm trying to evaluate the results of an LSTM using top_k_categorical_accuracy . For each One-Hot encoded token, I try to predict the next token. In order to do this I take the output for each instance in the sequence by using the TimeDistributed layer wrapper, and pass it to a Dense layer to re-encode the results into the same One-Hot encoding. While using the built in accuracy metric metrics=['accuracy'] works without a hitch, using top_k_categorical_accuracy fails, giving me the error

How to feed my output prediction value as next input value in LSTM model for future forcast model

拥有回忆 提交于 2020-01-05 07:09:13
问题 Here I am tried to predict next future value of x with three inputs. So here I used LSTM model to predict future value. Here is my code: num_time_step=2 from keras.layers import Masking from keras.layers import Activation from keras.layers import LeakyReLU model = Sequential() model.add(Masking(mask_value=0., input_shape=(num_time_step, x_train.shape[1]))) model.add(LSTM(4,return_sequences=True, input_dim=4)) model.add(LeakyReLU()) model.add(Dropout(0.01)) model.add(LSTM(8,return_sequences

3-vector series LSTM can't break 0.5 accuracy

≡放荡痞女 提交于 2020-01-05 06:27:08
问题 I have a toy series dataset of 3-vectors in the form of [[0, 0, 2], [1, 0, 3], [2, 0, 4], [3, 0, 2], [4, 0, 3], [5, 0, 4] ... [10001, 0, 4]] x always goes up by one, y is always 0, z repeats 2, 3, 4. I want to predict the next 3-vector in the sequence given a starting sequence. I'm using a window size of 32, but have also tried 256 with identical results. I normalize each dimension to be between 0 and 1 before sending it into the model. No matter how many layers, units, of number of features

How to create end execute a basic LSTM network in TensorFlow?

拜拜、爱过 提交于 2020-01-05 04:36:09
问题 I want to create a basic LSTM network that accept sequences of 5 dimensional vectors (for example as a N x 5 arrays) and returns the corresponding sequences of 4 dimensional hidden- and cell-vectors (N x 4 arrays), where N is the number of time steps. How can I do it TensorFlow? ADDED So, far I got the following code working: num_units = 4 lstm = tf.nn.rnn_cell.LSTMCell(num_units = num_units) timesteps = 18 num_input = 5 X = tf.placeholder("float", [None, timesteps, num_input]) x = tf.unstack

deep learning (lstm) with keras and variable size of inputs

拟墨画扇 提交于 2020-01-05 04:13:13
问题 I am trying to implement a lstm model with keras. The problem is that I have data of different shapes. My data looks like this: col1 col2 col3 col4 col5 [1,2,3] [2,3,4] [3,4,5] [5,6,7] [4,5,9] [0,2] [1,5] [1,24] [11,7] [-1,4] [0,2,4,5] [1,5,7,8] [1,24,-7,6] [11,7,4,5] [-1,4,1,2] My code is import numpy as np import pandas as pd import h5py from sklearn.model_selection import train_test_split from keras.layers import Dense from keras.layers import Input, LSTM from keras.models import Model X

【翻译】理解 LSTM 网络

折月煮酒 提交于 2020-01-05 02:01:10
目录 理解 LSTM 网络 递归神经网络 长期依赖性问题 LSTM 网络 LSTM 的核心想法 逐步解析 LSTM 的流程 长短期记忆的变种 结论 鸣谢 本文翻译自 Christopher Olah 的博文 Understanding LSTM Networks ,原文以图文并茂的形式,深入浅出地为初学者介绍了 LSTM 网络。 【翻译】理解 LSTM 及其图示 或许可以进一步帮助理解。 理解 LSTM 网络 Understanding LSTM Networks 递归神经网络 Recurrent Neural Networks 人类并不是时刻都从头开始思考。如果你阅读这篇文章,你是在之前词汇的基础上理解每一个词汇,你不需要丢掉一切从头开始思考。你的思想具有延续性。 传统的神经网络无法做到这样,并且这成为了一个主要的缺陷。例如,想像一下你需要对一部电影中正在发生的事件做出判断。目前还不清楚传统的神经网络如何根据先前发生的事件来推测之后发生的事件。 递归神经网络正好用来解决这个问题。递归神经网络的内部存在着循环,用来保持信息的延续性。 Humans don't start their thinking from scratch every second. As you read this essay, you understand each word based on your

(译)理解 LSTM 网络 (Understanding LSTM Networks by colah)

天涯浪子 提交于 2020-01-05 01:58:24
@翻译:huangyongye 原文链接: Understanding LSTM Networks 前言 :其实之前就已经用过 LSTM 了,是在深度学习框架 keras 上直接用的,但是到现在对LSTM详细的网络结构还是不了解,心里牵挂着难受呀!今天看了 tensorflow 文档上面推荐的这篇博文,看完这后,焕然大悟,对 LSTM 的结构理解基本上没有太大问题。此博文写得真真真好!!!为了帮助大家理解,也是怕日后自己对这些有遗忘的话可以迅速回想起来,所以打算对原文写个翻译。首先声明,由于本人水平有限,如有翻译不好或理解有误的多多指出!此外,本译文也不是和原文一字一句对应的,为了方便理解可能会做一些调整和修改。另外本文是作为我自己的学习笔记,没有经过原作者本人的授权,所以请勿转载) 1. 循环神经网络(RNNs) 人们思考问题往往不是从零开始的。就好像你现在阅读这篇文章一样,你对每个词的理解都会依赖于你前面看到的一些词,而不是把你前面看的内容全部抛弃了,忘记了,再去理解这个单词。也就是说,人们的思维总是会有延续性的。 传统的神经网络是做不到这样的延续性(它们没办法保留对前文的理解),这似乎成了它们一个巨大的缺陷。举个例子,在观看影片中,你想办法去对每一帧画面上正在发生的事情做一个分类理解。目前还没有明确的办法利用传统的网络把对影片中前面发生的事件添加进来帮助理解后面的画面。 但是

Tensorflow: Can't overfit training data with batch size > 1

霸气de小男生 提交于 2020-01-04 07:28:08
问题 I coded a small RNN network with Tensorflow to return the total energy consumption given some parameters. There seem to be a problem in my code. It can't overfit the training data when I use a batch size > 1 (even with only 4 samples!). In the code below, the loss value reaches 0 when I set BatchSize to 1. However, by setting BatchSize to 2, the network fails to overfit and the loss value goes toward 12.500000 and gets stuck there forever. I suspect this has something to do with LSTM states.