linguishi / chinese_sentiment Goto Github PK
View Code? Open in Web Editor NEW中文情感分析,CNN,BI-LSTM,文本分类
中文情感分析,CNN,BI-LSTM,文本分类
我最近在学习有关情感分析的内容,在运行你的代码时进行到最后一步没有找到模型导出的save_model.py是否能请您上传一下
还有就是在训练CNN目录下的main.py的时候,最终的准确率非常低。
Saving dict for global step 16074: acc = 0.610625, global_step = 16074, loss = 0.6398508, precision = 0.5851781, recall = 0.76
Saving 'checkpoint_path' summary for global step 16074: results/model\model.ckpt-16074
Loss for final step: 0.586049.
Traceback (most recent call last):
File "···/chinese_sentiment-master/data/hotel_comment/raw_data/fix_coupus.py", line 30, in
fix_corpus(POS, FIX_POS)
File "···/chinese_sentiment-master/data/hotel_comment/raw_data/fix_coupus.py", line 15, in fix_corpus
fix_s = s.decode('gb2312')
AttributeError: 'str' object has no attribute 'decode'
代码如下:
def fix_corpus(dir_s, dir_t):
for item in os.listdir(dir_s):
with open(os.path.join(dir_s, item), 'r',) as f:
try:
s = f.read()
fix_s = s.decode('gb2312')
except UnicodeDecodeError:
try:
fix_s = s.decode('gbk')
except UnicodeDecodeError:
fix_s = s.decode('gb2312', errors='ignore')
with codecs.open(os.path.join(dir_t, item), 'w', encoding='utf8') as ff:
ff.write(fix_s)
目前tensorflow没有1x版本了但是代码还是1x的版本的,在代码中采取.compat.v1的方式之后,有部分代码依旧无法使用AttributeError: module 'tensorflow._api.v2.compat.v1.compat.v1' has no attribute 'estimator'
请问如何解决
Hello, may I ask how to solve the fitting phenomenon
C:\ai\chinese_sentiment\venv\Scripts\python.exe C:\ai\chinese_sentiment\data\hotel_comment\build_embedings.py
Traceback (most recent call last):
File "C:\ai\chinese_sentiment\data\hotel_comment\build_embedings.py", line 6, in
word_to_idx = {line.strip(): idx for idx, line in enumerate(f)}
File "C:\ai\chinese_sentiment\data\hotel_comment\build_embedings.py", line 6, in
word_to_idx = {line.strip(): idx for idx, line in enumerate(f)}
File "C:\Program Files\Python38\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd7 in position 3382: invalid continuation byte
Process finished with exit code 1
main.py 文件中第72行和第73行 embeddings = tf.nn.embedding_lookup(w2v_var, word_ids)
nn.embedding_lookup有个模块已经停用了,如果在cpu上跑不会返回零tesor会报错。请问该怎么办呢?
InvalidArgumentError (see above for traceback): indices[18,130] = 21492 is not in [0, 3621)
[[node embedding_lookup (defined at main.py:73) = GatherV2[Taxis=DT_INT32, Tindices=DT_INT64, Tparams=DT_FLOAT, _device="/
job:localhost/replica:0/task:0/device:CPU:0"](Variable/read, string_to_index_Lookup, embedding_lookup/axis)]]
2023-10-18 17:24:37.709628: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties:
2023-10-18 17:24:37.716526: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
2023-10-18 17:24:37.721962: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_100.dll
2023-10-18 17:24:37.728865: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_100.dll
2023-10-18 17:24:37.735798: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_100.dll
2023-10-18 17:24:37.747056: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_100.dll
2023-10-18 17:24:37.752686: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_100.dll
2023-10-18 17:24:37.764038: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2023-10-18 17:24:37.769760: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0
2023-10-18 17:24:37.776367: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-10-18 17:24:37.783494: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0
2023-10-18 17:24:37.788907: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N
2023-10-18 17:24:37.793320: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4831 MB memory) -> physical GPU
这种信息是哪个模块输出的,找了一大圈没找到
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.