文件 "cnn_keras.py" 第 51 行,在训练中,打开( "train_images" , "rb" , "wb" ) 为 f:类型错误:需要一个整数(得到类型 str)



我是个新手,无法解决这个错误,有人能帮我吗我试图使用keras训练一个模型,但得到了一个错误,即TypeError:需要一个整数(得到类型str(错误在粗体这是代码:

def train():
with open("train_images", "rb","wb") as f:
train_images = np.array(pickle.load(f))

with open("train_labels", "rb") as f:
train_labels = np.array(pickle.load(f), dtype=np.int32)
with open("val_images", "rb") as f:
val_images = np.array(pickle.load(f))
with open("val_labels", "rb") as f:
val_labels = np.array(pickle.load(f), dtype=np.int32)

这是输出:

(mega) G:sign languageSign-Language-master>python cnn_keras.py
Using TensorFlow backend.
Traceback (most recent call last):
File "cnn_keras.py", line 76, in <module>
train()
File "cnn_keras.py", line 51, in train
with open("train_images", "rb","wb") as f:
TypeError: an integer is required (got type str)

有人能给我一些解决的方法吗

您必须删除第二行的"wb"

相关内容

最新更新