Frank-Wang-oss / FCSTGNN

86 stars 12 forks source link

main_HAR.py运行报错 #3

Open xiatian815 opened 11 months ago

xiatian815 commented 11 months ago

def Train_model(self): epoch = self.args.epoch cross_accu = 0 testaccu = [] prediction = [] real = []

    for i in range(epoch):
        time0 = time.time()
        loss = self.Train_batch()
        if i%self.args.show_interval == 0:
            accu_val = self.Cross_validation()

            if accu_val > cross_accu:
                cross_accu = accu_val
                test_accu, prediction, real = self.Prediction()

                print('In the {}th epoch, TESTING accuracy is {}%'.format(i, np.round(test_accu, 3)))
                test_accu_.append(test_accu)
                prediction_.append(prediction)
                real_.append(real)

    np.save('E:/FC_STGNN/experiment/{}.npy'.format(self.args.save_name),[test_accu_, prediction_, real_])运行到这里报错

发生异常: ValueError setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (3, 9) + inhomogeneous part. File "E:\FC_STGNN\main_HAR.py", line 67, in Train_model np.save('E:/FC_STGNN/experiment/{}.npy'.format(self.args.save_name),[testaccu, prediction, real]) File "E:\FC_STGNN\main_HAR.py", line 167, in train.Train_model() ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (3, 9) + inhomogeneous part.

Frank-Wang-oss commented 10 months ago

Hi I have no such bugs, which may be because of different numpy versions (I am using numpy 1.22).

RolandTate commented 6 months ago

I meet the same problem. Have u solve it?

xiongbaobao814 commented 3 months ago

我也遇见了一样的问题,请问有朋友解决了吗?