hit-computer / mta-lstm Goto Github PK
View Code? Open in Web Editor NEWThe code and data of ijcai2018 paper <Topic-to-Essay Generation with Neural Networks>
The code and data of ijcai2018 paper <Topic-to-Essay Generation with Neural Networks>
word_vec.pkl file(this is word embedding) and word_vec.pkl file(vocabulary of text).
word_vec = cPickle.load(open('word_vec.pkl', 'r'))
vocab = cPickle.load(open('word_voc.pkl','r'))
Hello:
I use python 2.7 and tensor flow 1.4, when I run python Train.py, the following error occurs.
Could you please help me ? Thanks @hit-computer
Traceback (most recent call last):
File "/Users/jiangwei/git/topic_essay/Train.py", line 260, in <module>
tf.app.run()
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "/Users/jiangwei/git/topic_essay/Train.py", line 235, in main
m = Model(is_training=True, config=config, filename='coverage_data')
File "/Users/jiangwei/git/topic_essay/Train.py", line 122, in __init__
(cell_output, state) = cell(tf.concat([inputs[:, time_step, :], mt], axis=1), state)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 183, in __call__
return super(RNNCell, self).__call__(inputs, state)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 575, in __call__
outputs = self.call(inputs, *args, **kwargs)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1066, in call
cur_inp, new_state = cell(cur_inp, cur_state)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 891, in __call__
output, new_state = self._cell(inputs, state, scope)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 183, in __call__
return super(RNNCell, self).__call__(inputs, state)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 575, in __call__
outputs = self.call(inputs, *args, **kwargs)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 611, in call
lstm_matrix = self._linear1([inputs, m_prev])
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1189, in __call__
res = math_ops.matmul(array_ops.concat(args, 1), self._weights)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/math_ops.py", line 1891, in matmul
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/ops/gen_math_ops.py", line 2437, in _mat_mul
name=name)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2958, in create_op
set_shapes_for_outputs(ret)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2209, in set_shapes_for_outputs
shapes = shape_func(op)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2159, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 627, in call_cpp_shape_fn
require_shape_fn)
File "/Users/jiangwei/anaconda/envs/tensorflow-1.4-py2.7/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 691, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Dimensions must be equal, but are 40 and 220 for 'model/RNN/RNN_sentence/RNN_sentence/multi_rnn_cell/cell_0/cell_0/lstm_cell/MatMul_1' (op: 'MatMul') with input shapes: [16,40], [220,80].
Process finished with exit code 1
class Config(object):
data_dir = 'Data/'
#vec_file = 'Data/wiki-zh.word2vec.txt'
vec_file = 'Data/TrainingData.word2vec.txt'
init_scale = 0.04
learning_rate = 0.001
max_grad_norm = 10 #gradient clipping
num_layers = 2
num_steps = 151
hidden_size = 20
#word_embedding_size = 10
word_embedding_size = 100
max_epoch = 30
max_max_epoch = 80
keep_prob = 0.5 #The probability that each element is kept through dropout layer
lr_decay = 1.0
batch_size = 16
vocab_size = 92161
num_keywords = 5
save_freq = 10 #The step (counted by the number of iterations) at which the model is saved to hard disk.
model_path = './Model_News' #the path of model that need to save or load
# parameter for generation
len_of_generation = 16 #The number of characters by generated
save_time = 20 #load save_time saved models
is_sample = True #true means using sample, if not using argmax
BeamSize = 2
I would like to ask which directory the data files of the two datasets are located in.
请问有人下载好了数据集吗?求分享~谢谢
In the README.md:
word_vec.pkl file(this is word embedding) and word_vec.pkl file(vocabulary of text).
the second word_vec.pkl should be word_voc.pkl
Thanks, a great work!
Hi,
I read your paper a few weeks ago, it is a brilliant idea. I'd like to train a model with the dataset you provided. But my computing power is limited. Could you suggest how long it takes when you performed it and the platform (#gpus, or #cpus, and memory) you were working with?
Thanks!
File "Preprocess.py", line 128, in data_iterator
key_words = np.array(key_words, dtype=np.int64)
ValueError: setting an array element with a sequence.
My input file has multiple length how to fix this?
errors
I would like to ask, is the Data/vec.txt file generated by myself? Does your program have the code to generate this file?
Just heads up for who else will use this later.
When you use gensim to train word2vec model, plz save it to not binary type. Otherwise, it will raise decode problem when running Preprocess.py.
Hello all,
The links given in the readme for the dataset cannot be reached . Is there any other way to download the data set ?
The beam search code can only use for single generation each time, but for evaluation it can costs lots time. Can anybody help make it parallel? Thx a lot.
Dear hit-computer
I m' newbie. I read your readme and do not understand how to create TrainingData.txt and vec.txt from Composition Data Set and Zhihu Data Set.
Please help me.
I found new version of your code, but i thing i need understand this version before read new version.
zhihu数据集上面很多话题不再段落当中,没办法使用语言模型,请问这些话题的词向量是怎么得到的,而且有很多,
请问一下第二个cost2是什么意思啊,不明白为什么是两种权重的差值的平方
冒昧的问一句,能否分享下您们的model文件。这样我们在不用train的情况下,也能尝试效果,非常感谢
I want to generate some essays using the pretrained model. Can you please send me the pretrained model file and two files: word_vec.pkl and word_voc.pkl ?
i am getting Error for Loading Files
loading the trainingdata...
Traceback (most recent call last):
File "Preprocess.py", line 89, in
data = Read_Train_Data(config)
File "Preprocess.py", line 55, in Read_Train_Data
idx = tmp.index('< /d>')
ValueError: '< /d>' is not in list
TrainingData.txt能说下什么格式吗
请问一下你们的词典真的只用了5万个吗,那不是会出现很多unk?我不清楚这5万个词是只作为预测的候选词还是所有的词典,我看那个作文的数据集有几十万个词,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.