microsoft / CNTK

Microsoft Cognitive Toolkit (CNTK), an open source deep-learning toolkit
https://docs.microsoft.com/cognitive-toolkit/
Other
17.49k stars 4.3k forks source link

SequenceClassification.py does not work out of box #3875

Open HaomingYu1997 opened 1 year ago

HaomingYu1997 commented 1 year ago

I use Visual Studio 2022 to run the SequenceClassification.py. The Python version I am using is 3.6.8, the CNTK version is cntk-gpu-2.7. However, when I run the program these errors came up:

About to throw exception 'Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open.'
attempt: Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open., retrying 2-th time out of 5...

About to throw exception 'Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open.'
attempt: Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open., retrying 3-th time out of 5...

About to throw exception 'Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open.'
attempt: Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open., retrying 4-th time out of 5...

About to throw exception 'Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open.'
attempt: Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open., retrying 5-th time out of 5...

About to throw exception 'Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open.'
Input file 'F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt' is not open.

The call stacks are

[CALL STACK]
    > 00007FFEF35CD7DB (SymFromAddr() error: Attempt to access invalid address.)
    - 00007FFEF35CEB5D (SymFromAddr() error: Attempt to access invalid address.)
    - 00007FFEF35D5B28 (SymFromAddr() error: Attempt to access invalid address.)
    - 00007FFEF35CE055 (SymFromAddr() error: Attempt to access invalid address.)
    - CreateDeserializer
    - CreateCompositeDataReader (x3)
    - CNTK::  UniversalLearner
    - CNTK::  CreateCompositeMinibatchSource
    - PyInit__cntk_py
    - PyCFunction_FastCallDict
    - PyObject_GetAttr
    - PyEval_EvalFrameDefault
    - PyObject_Free
    - PyFunction_FastCallDict

Stack trace:

Stack trace:
 >  File "F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\LSTM_GloVe.py", line 17, in create_reader
 >    )), randomize=is_training,max_sweeps=INFINITELY_REPEAT if is_training else 1)
 >  File "F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\LSTM_GloVe.py", line 52, in train_sequence_classifier
 >    reader = create_reader(path, True, input_dim, num_output_classes)
 >  File "F:\purdue\2022_Fall\ECE_62900\final_project\LSTM_GloVe\LSTM_GloVe.py", line 78, in <module> (Current frame)
 >    error, _ = train_sequence_classifier()
Loaded 'cntk.io'
Loaded '__main__'
Loaded 'runpy'
The program 'python.exe' has exited with code 0 (0x0).

I have looked at issue #2999. The suggestion is: In the path in your code, add .txt at the end, e.g. '../../Tests/EndToEndTests/Image/Data\Train_cntk_text.txt.txt'. This didn't work for me.

Are they any other suggestions?

pat749 commented 1 year ago

The error message suggests that the input file "Train_cntk_text.txt.txt" cannot be found or opened. The path of the file seems to be incorrect since it contains duplicate ".txt" extensions. You may want to check the file path and make sure it is correct. Additionally, you may want to try using an absolute file path instead of a relative path. To do so, you can use the os module to get the absolute path of the file as follows:

import os

file_path = "Train_cntk_text.txt.txt"
abs_path = os.path.abspath(file_path)

# pass abs_path to your CNTK code

This will give you the absolute path of the file, which you can use to load the data in your CNTK code.