AttributeError:'numpy.ndarray'对象没有属性'\u assert\u compile\u was\u called'

2024-09-29 19:23:49 发布

您现在位置:Python中文网/ 问答频道 /正文

如何解决这个问题。我认为这是更新错误的类型。请帮助解决此问题

result = np.apply_along_axis(augment, axis=1, arr=X[C3]).reshape(-1, 187)
classe = np.ones(shape=(result.shape[0],), dtype=int)*3
X = np.vstack([X, result])
y = np.hstack([y, classe])
subC0 = np.random.choice(C0, 800)
subC1 = np.random.choice(C1, 800)
subC2 = np.random.choice(C2, 800)
subC3 = np.random.choice(C3, 800)
subC4 = np.random.choice(C4, 800)
X_test = np.vstack([X[subC0], X[subC1], X[subC2], X[subC3], X[subC4]])
y_test = np.hstack([y[subC0], y[subC1], y[subC2], y[subC3], y[subC4]])

X_train = np.delete(X, [subC0, subC1, subC2, subC3, subC4], axis=0)
y_train = np.delete(y, [subC0, subC1, subC2, subC3, subC4], axis=0)

X_train, y_train = shuffle(X_train, y_train, random_state=0)
X_test, y_test = shuffle(X_test, y_test, random_state=0)

del X
del y
X_train = np.expand_dims(X_train, 2)
X_test = np.expand_dims(X_test, 2)
history = tensorflow.keras.Model.fit(X_train, y_train, 
                epochs=75, 
                batch_size=batch_size, 
                verbose=2, 
                validation_data=(X_test, y_test), 
                callbacks= [lrate])

它正在处理我以前版本的python。但现在它被证明是错误的一些错误,请帮助解决这个问题


Tags: test错误nptrainrandomresultchoiceaxis
1条回答
网友
1楼 · 发布于 2024-09-29 19:23:49

从您提供的源代码来看,我认为您从未创建或编译过模型?您似乎没有首先创建模型类的实例就直接调用了fit方法

Tensorflow网站上有一个很好的指南,可以指导您如何创建Keras模型:https://www.tensorflow.org/guide/keras/train_and_evaluate

相关问题 更多 >

    热门问题