尝试运行深度学习测试代码后,我在Pycham中出错

时间:2020-07-06 05:00:16

标签: deep-learning pycharm

# USAGE
# python train_simple_nn.py --dataset animals --model output/simple_nn.model --label-bin output/simple_nn_lb.pickle --plot output/simple_nn_plot.png

# set the matplotlib backend so figures can be saved in the background
import matplotlib
matplotlib.use("Agg")



# import the necessary packages
from sklearn.preprocessing import LabelBinarizer
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.optimizers import SGD
from imutils import paths
import matplotlib.pyplot as plt
import numpy as np
import argparse
import random
import pickle
import cv2
import os



# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-d", "--dataset", required=True, help="path to input dataset of images")
ap.add_argument("-m", "--model", required=True, help="path to output trained model")
ap.add_argument("-l", "--label-bin", required=True, help="path to output label binarizer")
ap.add_argument("-p", "--plot", required=True, help="path to output accuracy/loss plot")
args = vars(ap.parse_args())

# initialize the data and labels
print("[INFO] loading images...")
data = []
labels = []

# grab the image paths and randomly shuffle them
imagePaths = sorted(list(paths.list_images(args["dataset"])))
random.seed(42)
random.shuffle(imagePaths)

# loop over the input images
for imagePath in imagePaths:
    # load the image, resize the image to be 32x32 pixels (ignoring
    # aspect ratio), flatten the image into 32x32x3=3072 pixel image
    # into a list, and store the image in the data list
    image = cv2.imread(imagePath)
    image = cv2.resize(image, (32, 32)).flatten()
    data.append(image)

    # extract the class label from the image path and update the
    # labels list
    label = imagePath.split(os.path.sep)[-2]
    labels.append(label)

# scale the raw pixel intensities to the range [0, 1]
data = np.array(data, dtype="float") / 255.0
labels = np.array(labels)

我找到了学习深度学习的测试代码。 并试图在皮查姆运行。但我收到此错误消息。 实际上,我不明白该解析器函数在做什么。 您能解释一下该代码和错误吗?

--我在皮查姆(Pycharm)中遇到的错误----------------------- C:\ Users \ giyeo \ anaconda3 \ envs \ tf \ python.exe“ D:/ GiyeonLee / 09。机器学习/Pycharm/Tutorial/keras-tutorial/train_simple_nn.py” 2020-07-06 13:56:28.409237:我tensorflow / stream_executor / platform / default / dso_loader.cc:44]成功打开动态库cudart64_101.dll 用法:train_simple_nn.py [-h] -d数据集-m模型-l LABEL_BIN -p图 train_simple_nn.py:错误:需要以下参数:-d /-dataset,-m /-model,-l /-label-bin,-p /-plot

进程退出代码为2

感谢您阅读我的语录。

0 个答案:

没有答案