Comments (3)
是你的文件编码的问题
from chatbot.
execute.py下的decode_line()函数会把中文词转为二进制表示,所以在词字典中是找不到的,token_ids一直是[3,3,3,3…]
你好,我的也是这样,请问你解决了没
from chatbot.
execute.py下的decode_line()函数会把中文词转为二进制表示,所以在词字典中是找不到的,token_ids一直是[3,3,3,3…]
你好,我的也是这样,请问你解决了没
有点记不清当时都改了哪些地方,我把大佬的代码注释了一部分,绕过了转二进制部分。其他地方有没有修改不是太确定了。
def decode_line(sess, model, enc_vocab, rev_dec_vocab, sentence):
# Get token-ids for the input sentence.
#token_ids = prepareData.sentence_to_token_ids(tf.compat.as_bytes(sentence), enc_vocab)
#token_ids = prepareData.sentence_to_token_ids(sentence, enc_vocab)
def sentence_to_token_ids(sentence, enc_vocab):
token_ids=[]
for word in re.split(r'\s+',sentence):
token_ids.append(enc_vocab.get(word,3))
return(token_ids)
token_ids=sentence_to_token_ids(sentence,enc_vocab)
# Which bucket does it belong to?
bucket_id = min([b for b in xrange(len(_buckets)) if _buckets[b][0] > len(token_ids)])
# Get a 1-element batch to feed the sentence to the model.
encoder_inputs, decoder_inputs, target_weights = model.get_batch({bucket_id: [(token_ids, [])]}, bucket_id)
# Get output logits for the sentence.
_, _, output_logits = model.step(sess, encoder_inputs, decoder_inputs, target_weights, bucket_id, True)
# This is a greedy decoder - outputs are just argmaxes of output_logits.
outputs = [int(np.argmax(logit, axis=1)) for logit in output_logits]
# If there is an EOS symbol in outputs, cut them at that point.
if prepareData.EOS_ID in outputs:
outputs = outputs[:outputs.index(prepareData.EOS_ID)]
return " ".join([tf.compat.as_str(rev_dec_vocab[output]) for output in outputs])
from chatbot.
Related Issues (20)
- 训练时报错invalid file name: model_data/.pt HOT 3
- pytorch模型中,执行execute.py ,提示没有seq.data HOT 2
- 聊天报错error calling function:AttributeError: 'Request' object has no attribute 'is_xhr' HOT 4
- 如何实现FAQ?
- 一直显示no module要怎么办? HOT 1
- execute.py 一直报错 HOT 3
- 关于微调和运行
- 报错问题
- 完成训练时候save 档案出现问题 HOT 1
- 数据问题
- 如果app.py放在web里面就无法运行,拿出来之后error calling function HOT 3
- 缺少'train_data/seq.data'文件,Tensowflow2.0的Seq2seq版本 HOT 2
- Pytorch版本:max_train_data_size设置为多少比较合理?
- 请问智能客服功能完善了吗?可以作为业务客服来使用吗?
- 请问如果用自己的数据进行微调的话,怎么解决模块加载时,形状不匹配的问题?
- 微信群二维码过期咯 HOT 2
- 提示error calling function怎么办的 HOT 2
- Chatbot Report
- 运行app.py时出现error calling function HOT 3
- 训练完提示形状不匹配啊
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatbot.