sequence-to-sequence

How should we pad text sequence in keras using pad_sequences?

落爺英雄遲暮 提交于 2019-12-05 21:35:27
问题 I have coded a sequence to sequence learning LSTM in keras myself using the knowledge gained from the web tutorials and my own intuitions. I converted my sample text to sequences and then padded using pad_sequence function in keras. from keras.preprocessing.text import Tokenizer,base_filter from keras.preprocessing.sequence import pad_sequences def shift(seq, n): n = n % len(seq) return seq[n:] + seq[:n] txt="abcdefghijklmn"*100 tk = Tokenizer(nb_words=2000, filters=base_filter(), lower=True,

How should we pad text sequence in keras using pad_sequences?

我的梦境 提交于 2019-12-04 03:21:12
I have coded a sequence to sequence learning LSTM in keras myself using the knowledge gained from the web tutorials and my own intuitions. I converted my sample text to sequences and then padded using pad_sequence function in keras. from keras.preprocessing.text import Tokenizer,base_filter from keras.preprocessing.sequence import pad_sequences def shift(seq, n): n = n % len(seq) return seq[n:] + seq[:n] txt="abcdefghijklmn"*100 tk = Tokenizer(nb_words=2000, filters=base_filter(), lower=True, split=" ") tk.fit_on_texts(txt) x = tk.texts_to_sequences(txt) #shifing to left y = shift(x,1)

How to convert predicted sequence back to text in keras?

天涯浪子 提交于 2019-11-30 01:13:46
问题 I have a sequence to sequence learning model which works fine and able to predict some outputs. The problem is I have no idea how to convert the output back to text sequence. This is my code. from keras.preprocessing.text import Tokenizer,base_filter from keras.preprocessing.sequence import pad_sequences from keras.models import Sequential from keras.layers import Dense txt1="""What makes this problem difficult is that the sequences can vary in length, be comprised of a very large vocabulary

scheduled sampling in Tensorflow

99封情书 提交于 2019-11-29 19:34:14
问题 The newest Tensorflow api about seq2seq model has included scheduled sampling: https://www.tensorflow.org/api_docs/python/tf/contrib/seq2seq/ScheduledEmbeddingTrainingHelper https://www.tensorflow.org/api_docs/python/tf/contrib/seq2seq/ScheduledOutputTrainingHelper The original paper of scheduled sampling can be found here: https://arxiv.org/abs/1506.03099 I read the paper but I cannot understand the difference between ScheduledEmbeddingTrainingHelper and ScheduledOutputTrainingHelper . The

TypeError: can't pickle _thread.lock objects in Seq2Seq

时光总嘲笑我的痴心妄想 提交于 2019-11-28 00:56:25
I'm having trouble using buckets in my Tensorflow model. When I run it with buckets = [(100, 100)] , it works fine. When I run it with buckets = [(100, 100), (200, 200)] it doesn't work at all (stacktrace at bottom). Interestingly, running Tensorflow's Seq2Seq tutorial gives the same kind of issue with a nearly identical stacktrace. For testing purposes, the link to the repository is here . I'm not sure what the issue is, but having more than one bucket always seems to trigger it. This code won't work as a standalone, but this is the function where it is crashing - remember that changing

Visualizing attention activation in Tensorflow

谁都会走 提交于 2019-11-27 15:01:07
问题 Is there a way to visualize the attention weights on some input like the figure in the link above(from Bahdanau et al., 2014), in TensorFlow's seq2seq models? I have found TensorFlow's github issue regarding this, but I couldn't find out how to fetch the attention mask during the session. 回答1: I also want to visualize the attention weights of Tensorflow seq2seq ops for my text summarization task. And I think the temporary solution is to use session.run() to evaluate the attention mask tensor

TypeError: can't pickle _thread.lock objects in Seq2Seq

天大地大妈咪最大 提交于 2019-11-26 23:20:56
问题 I'm having trouble using buckets in my Tensorflow model. When I run it with buckets = [(100, 100)] , it works fine. When I run it with buckets = [(100, 100), (200, 200)] it doesn't work at all (stacktrace at bottom). Interestingly, running Tensorflow's Seq2Seq tutorial gives the same kind of issue with a nearly identical stacktrace. For testing purposes, the link to the repository is here. I'm not sure what the issue is, but having more than one bucket always seems to trigger it. This code