我无法将数据加载到代码中并解析它。我附上下面的代码
ap = argparse.ArgumentParser()
ap.add_argument("-a", "--az", required=True,
help="path to A-Z dataset")
ap.add_argument("-m", "--model", type=str, required=True,
help="path to output trained handwriting recognition model")
ap.add_argument("-p", "--plot", type=str, default="plot.png",
help="path to output training history file")
args = vars(ap.parse_args())
上面跟着下面的代码
# load the A-Z and MNIST datasets, respectively
print("[INFO] loading datasets...")
(azData, azLabels) = load_az_dataset(args["az"])
(digitsData, digitsLabels) = load_mnist_dataset()
我已经保存了数据,图像和模型
我的数据结构是这样的
.
├── a_z_handwritten_data.csv
├── handwriting.model
├── plot.png
├── train_ocr_model.ipynb
└── train_ocr_model.py
错误如下:
ap = argparse.ArgumentParser()
ap.add_argument("-a", "--az", required=True,
help="path to A-Z dataset")
ap.add_argument("-m", "--model", type=str, required=True,
help="path to output trained handwriting recognition model")
ap.add_argument("-p", "--plot", type=str, default="plot.png",
help="path to output training history file")
args = vars(ap.parse_args())
usage: ipykernel_launcher.py [-h] -a AZ -m MODEL [-p PLOT]
ipykernel_launcher.py: error: the following arguments are required: -a/--az, -m/--model
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
另一个错误是:
print("[INFO] loading datasets...")
(azData, azLabels) = load_az_dataset(r'a_z_handwritten_data.csv')
(digitsData, digitsLabels) = load_mnist_dataset()
[INFO] loading datasets...
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-1e649190daf8> in <module>
4
5 print("[INFO] loading datasets...")
----> 6 (azData, azLabels) = pd.read_csv(r'a_z_handwritten_data.csv')
7 (digitsData, digitsLabels) = load_mnist_dataset()
ValueError: too many values to unpack (expected 2)
问题出在以下代码
(azData, azLabels) = load_az_dataset(r'a_z_handwritten_data.csv')
用下面的代码替换上面的代码段。
hand_written_data = load_az_dataset(r'a_z_handwritten_data.csv')
那么这个问题将被修复。请访问以下链接以获取有关该错误的更多详细信息。https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html