python:3.x
tensorflow 1.x
运行训练:python train.py
运行验证:python eval.py
如有问题欢迎讨论 [email protected]
基于tensorflow 实现的用textcnn方法做情感分析的项目,有数据,可以直接跑。
python:3.x
tensorflow 1.x
运行训练:python train.py
运行验证:python eval.py
如有问题欢迎讨论 [email protected]
请问这个是怎么生成的
想问下这个数据是从哪里来的哈
多谢分享请问有没有可以使用自己词向量的加attention的bi-lstm的模型呀
`u@u-VirtualBox:~/sentiment_analysis_textcnn/textcnn$ python train.py
Parameters:
ALLOW_SOFT_PLACEMENT=True
BATCH_SIZE=64
CHECKPOINT_EVERY=100
DEV_SAMPLE_PERCENTAGE=0.1
DROPOUT_KEEP_PROB=0.5
EMBEDDING_DIM=128
EVALUATE_EVERY=50
FILTER_SIZES=2,3,4
L2_REG_LAMBDA=0.0
LOG_DEVICE_PLACEMENT=False
NUM_CHECKPOINTS=5
NUM_EPOCHS=10
NUM_FILTERS=128
TRAIN_DATA_FILE=../data/cutclean_label_corpus10000.txt
TRAIN_LABEL_DATA_FILE=
W2V_FILE=../data/vectors.bin
Loading data...
Traceback (most recent call last):
File "train.py", line 226, in
train(w2v_wr.model)
File "train.py", line 93, in train
x_train, x_dev, y_train, y_dev ,vocab_size= load_data(w2v_model)
File "train.py", line 54, in load_data
x_text, y = data_helpers.load_data_and_labels(FLAGS.train_data_file)
File "/home/u/sentiment_analysis_textcnn/textcnn/data_input_helper.py", line 76, in load_data_and_labels
with open(filepath, 'r', encoding='utf-8',errors='ignore') as f:
TypeError: file() takes at most 3 arguments (4 given)`` eval
u@u-VirtualBox:~/sentiment_analysis_textcnn/textcnn$ python eval.py
Parameters:
ALLOW_SOFT_PLACEMENT=True
BATCH_SIZE=64
CHECKPOINT_DIR=./runs/1501842714/checkpoints/
EVAL_TRAIN=True
LOG_DEVICE_PLACEMENT=False
VALID_DATA_FILE=../data/cutclean_label_corpus10000.txt
W2V_FILE=../data/vectors.bin
2018-01-11 10:02:53.954545: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-11 10:02:53.954615: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-01-11 10:02:53.954634: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
Traceback (most recent call last):
File "eval.py", line 107, in
eval(w2v_wr.model)
File "eval.py", line 68, in eval
saver = tf.train.import_meta_graph("{}.meta".format(checkpoint_file))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1679, in import_meta_graph
meta_graph_def = meta_graph.read_meta_graph_file(meta_graph_or_file)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/meta_graph.py", line 402, in read_meta_graph_file
raise IOError("File %s does not exist." % filename)
IOError: File None.meta does not exist.
`
这个代码的data文件夹中,这里的txt文件和bin文件似乎是一一对应的,那么我想用新数据写好txt文件,怎么得到这里匹配的bin文件???求救
runfile('D:/sentiment_analysis_textcnn-master/textcnn/eval.py', wdir='D:/sentiment_analysis_textcnn-master/textcnn')
Reloaded modules: data_input_helper, text_cnn
Traceback (most recent call last):
File "D:\sentiment_analysis_textcnn-master\textcnn\eval.py", line 27, in
tf.flags.DEFINE_string("w2v_file", "../data/vectors.bin", "w2v_file path")
File "D:\caifeng\anaconda\envs\NewEnv\lib\site-packages\tensorflow\python\platform\flags.py", line 58, in wrapper
return original_function(*args, **kwargs)
File "D:\caifeng\anaconda\envs\NewEnv\lib\site-packages\absl\flags_defines.py", line 290, in DEFINE_string
**args)
File "D:\caifeng\anaconda\envs\NewEnv\lib\site-packages\absl\flags_defines.py", line 102, in DEFINE
module_name, required)
File "D:\caifeng\anaconda\envs\NewEnv\lib\site-packages\absl\flags_defines.py", line 136, in DEFINE_flag
fv[flag.name] = flag
File "D:\caifeng\anaconda\envs\NewEnv\lib\site-packages\absl\flags_flagvalues.py", line 429, in setitem
raise _exceptions.DuplicateFlagError.from_flag(name, self)
DuplicateFlagError: The flag 'w2v_file' is defined twice. First from D:\sentiment_analysis_textcnn-master\textcnn\train.py, Second from D:\sentiment_analysis_textcnn-master\textcnn\eval.py. Description from first occurrence: w2v_file path
l2_loss += tf.nn.l2_loss(b)
这里应该是
l2_loss += tf.nn.l2_loss(W)
l2损失正则应该是对W起作用,当然也可以同时加上loss(b),像原始版本的代码一样。
请问您这里用到的数据是谭松波酒店数据集吗?
AttributeError: 'Word2VecKeyedVectors' object has no attribute 'vocab_hash'
您好,这段代码能进行多标签分类吗
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.