luchi007 / rnn_text_classify Goto Github PK
View Code? Open in Web Editor NEWText classification using LSTM
License: Apache License 2.0
Text classification using LSTM
License: Apache License 2.0
dataset_path='data/subj0.pkl'
您好,我现在用自己的数据生成了pkl文件,格式跟您分享的subj0.pkl一样,但是执行代码时
train_set = np.array(pkl.load(f))
test_set = np.array(pkl.load(f))
这两句总是报错,提示:
test_set = np.array(pkl.load(f))
EOFError: Ran out of input
请问train_set和test_set是如何从pkl文件中获取的呢?我调试的时候发现train_set已经获取了pkl文件的全部数据了,请教一下:
train_set = np.array(pkl.load(f))
test_set = np.array(pkl.load(f))
这两句代码该怎么理解呢?还是事先对pkl文件分好训练集测试集了呢?谢谢您~
博主您好,我的tensorflow是1.4版本,按照这里之前的issue改了改终于能跑通,用的是您的数据和您的默认参数,可是验证集、测试集准确率很低,只有0.05,训练集倒是一开始就0.9了,请问是本来的准确率就这么低吗。。。
现在基本上用TF1.0+的人比较多,TF1.0之后很多方法不兼容TF 0.x的版本。
如果楼主方便的话~
Hi . thank u so much for your code about rnn. I want to run it in version 1.2.1. After some changes, I meet with an error which seems a little hard for me.
code:
self._initial_state = cell.zero_state(self.batch_size,dtype=tf.float32)
error:
TypeError: int() argument must be a string or a number, not 'Variable'
I know why this happens. but due to code structure, I won't change the type of batch_size. So what should I do? thank u.
@luchi007 ,看楼主的博客中网络架构只有一层,楼主为什么要用MultiRNNCell呢?
现在基本上用TF1.0+的人比较多,TF1.0之后很多方法不兼容TF 0.x的版本。
在tensoflow1.0中
用tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl 替代 tf.rnn_cell试试
另外在tensorflow1.0中,还有以下函数需要改
旧 | 新 |
---|---|
tf.train.SummaryWriter | tf.summary.FileWriter |
tf.scalar_summary | tf.summary.scalar |
tf.merge_summary | tf.summary.merge |
tf.histogram_summary | tf.summary.histogram |
tf.rnn_cell | tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl |
替换以上之后就能在TensorFlow1.0中运行了
你好,请问多分类问题怎么设置labels(targets), 比如说 二分类设置为0,1,三分类怎么设置labels , -1,0,1吗
你好,我已经用您给的数据(,pkl)成功复现了训练过程,但是当我用自己的数据测试时却发生了一下错误:
Traceback (most recent call last):
File "train_rnn_classify.py", line 177, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "train_rnn_classify.py", line 173, in main
train_step()
File "train_rnn_classify.py", line 157, in train_step
global_steps=run_epoch(model,session,train_data,global_steps,valid_model,valid_data,train_summary_writer,dev_summary_writer)
File "train_rnn_classify.py", line 96, in run_epoch
cost,accuracy,_,summary = session.run(fetches,feed_dict)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 717, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 915, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 985, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.InvalidArgumentError: Nan in summary histogram for: model/HistogramSummary_4
[[Node: model/HistogramSummary_4 = HistogramSummary[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"](model/HistogramSummary_4/tag, model/clip_by_global_norm/model/clip_by_global_norm/_4)]]
请问报错原因是社么?我输入的数据格式和您给的数据格式一致,都是第一项为句子链表,第二项为9或1链表。
谢谢
你好,在rnn_model.py中
out_put=out_put*self.mask_x[:,:,None]在执行的时候提示无法识别“None”类型
Am I correct that you feed the whole data at once into the LSTM? not sentence by sentence or paragraph?
Thanks
我看到在rnn_model.py init()中有对embedding层的初始化,
with tf.device("/cpu:0"),tf.name_scope("embedding_layer"):
embedding = tf.get_variable("embedding",[vocabulary_size,embed_dim],dtype=tf.float32)
inputs=tf.nn.embedding_lookup(embedding,self.input_data)
但是没看明白的是,在运行的时候,从哪里load embeddings呢?还是在哪里随机初始化了呢?
多谢指点!
self._initial_state = cell.zero_state(self.batch_size,dtype=tf.float32)
这一行报错:
TypeError: int() argument must be a string or a number, not 'Variable'
TensorFlow版本1.2.1
楼主您好,通过 path = saver.save(session,checkpoint_prefix,global_steps)保存下来的模型中,是不是包含了lstmcell内的参数,也就是忘记门、输入门、输出门的W和b,这些参数没有在代码中体现,也会被保存下来吗?
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.