TC-Bot icon indicating copy to clipboard operation
TC-Bot copied to clipboard

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

Open AtmaHou opened this issue 8 years ago • 8 comments

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.

AtmaHou avatar Sep 19 '17 12:09 AtmaHou

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?

Huyu2Jason avatar Mar 04 '18 12:03 Huyu2Jason

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

AtmaHou avatar Apr 25 '18 05:04 AtmaHou

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'?

vpegasus avatar Sep 05 '18 06:09 vpegasus

I am facing the same problem

wesleytao avatar Nov 01 '18 01:11 wesleytao

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

shibing624 avatar Dec 04 '18 13:12 shibing624

encoding='iso-8859-1'

On what platform are you running this code。

QiuSYang avatar Apr 21 '20 07:04 QiuSYang

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

hoomanvhd avatar Aug 30 '20 23:08 hoomanvhd

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

7huahua avatar Sep 04 '23 07:09 7huahua