Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to "ValueError: could not convert string to float:" #6

Open
AtmaHou opened this issue Sep 19, 2017 · 8 comments
Open

Fix to "ValueError: could not convert string to float:" #6

AtmaHou opened this issue Sep 19, 2017 · 8 comments

Comments

@AtmaHou
Copy link

AtmaHou commented Sep 19, 2017

When I try to run the code with Rule Agent's prams, I got this:
ValueError: could not convert string to float:
My solution is changing the file-pointer loading style from "rb" to "r", and it works for me.
Two place need to fix:

  • line 50 in nlu.py

  • line138 in nlg.py

I know someone may not encounter the error, and just could enjoy the code perfectly.

@Huyu2Jason
Copy link

I encountered the same question as you did.
I followed your guidance but I still face the question below.
Traceback (most recent call last):
File "run.py", line 213, in
nlg_model.load_nlg_model(nlg_model_path)
File "/home/jason/Jason/DialogueSystem/TC-Bot_U/src/deep_dialog/nlg/nlg.py", line 138, in load_nlg_model
model_params = pickle.load(open(model_path, 'r'))
ValueError: could not convert string to float

Could you please show me the way to solve this?

@AtmaHou
Copy link
Author

AtmaHou commented Apr 25, 2018

Hi,
My fix works only on windows, problem still remains for linux.
Maybe, you are running on linux?

@vpegasus
Copy link

vpegasus commented Sep 5, 2018

I encounter the problem too, and the solution doesn't work for me~ I don't understand why reading the model_path is related to 'convert string to float'?

@wesleytao
Copy link

I am facing the same problem

@shibing624
Copy link

change to : model_params = pickle.load(open(model_path, 'rb'), encoding='iso-8859-1')

@QiuSYang
Copy link

encoding='iso-8859-1'

On what platform are you running this code。

@hoomanvhd
Copy link

I encountered the same question as you did.
I followed your guidance but I still face the question below.
Traceback (most recent call last):
File "run.py", line 213, in
nlg_model.load_nlg_model(nlg_model_path)
File "/home/jason/Jason/DialogueSystem/TC-Bot_U/src/deep_dialog/nlg/nlg.py", line 138, in load_nlg_model
model_params = pickle.load(open(model_path, 'r'))
ValueError: could not convert string to float

Could you please show me the way to solve this?

The idea of loading pickle file is to load a binary coded file. since the models they have prepared are in string format you need to recreate the model files by loading the dictionaries out of the models by pickle.load and then dump it into another pickle file. or you can use different types of encoding on pickle.load

@7huahua
Copy link

7huahua commented Sep 4, 2023

dos2unix your_pickle_file.pk
Replacing end-of-line from CR+LF (\r\n) into LF (\n) works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants