# coding:utf-8 from MMEdu import MMDetection as det def generated_train(): model = det(backbone='Yolov3') model.num_classes = 3 model.load_dataset(path=r'D:\XEdu\datasets\mmedu_det\hand_gray') model.save_fold = r'D:\XEdu\my_checkpoints\mmedu_20231215_144712' model.train(epochs=5,validate=True,device='cpu',optimizer='SGD',lr=0.01, batch_size=None,weight_decay=0.001,checkpoint=None,random_seed=42) if __name__ == '__main__': generated_train()
鸢尾花yuan
# coding:utf-8 from BaseNN import nn def generated_train(): model = nn() model.load_tab_data(r'D:\XEdu\datasets\basenn\iris\iris_training.csv',y_type='long',batch_size=32) model.save_fold = r'D:\XEdu\my_checkpoints\basenn_20231215_145215' model.set_seed(42) model.add(optimizer='Adam') model.add(layer='linear',size=(4, 10),activation='relu') model.add(layer='linear',size=(10, 2),activation='relu') model.add(layer='linear',size=(2, 2),activation='softmax') model.train(epochs=5,lr=0.01,loss='CrossEntropyLoss',metrics=['acc']) if __name__ == '__main__': generated_train()
{'dataset': 'iris\\iris_training.csv', 'dataset_path': 'D:\\XEdu\\datasets\\basenn\\iris\\iris_training.csv', 'checkpoints_path': 'D:\\XEdu\\my_checkpoints\\basenn_20231215_150058', 'lr': 0.01, 'epochs': 10, 'network': [{'id': 1, 'type': 'linear', 'activation': 'relu', 'size': (4, 10)}, {'id': 2, 'type': 'linear', 'activation': 'relu', 'size': (10, 2)}, {'id': 3, 'type': 'linear', 'activation': 'softmax', 'size': (2, 2)}], 'pretrained_path': None, 'metrics': 'acc', 'loss': 'CrossEntropyLoss', 'random_seed': 42, 'batch_size': 32, 'optimizer': 'Adam'} {'message': None, 'IsRunning': True, 'time_stamp': '20231215_150058', 'train_times': 1, 'pid': None} basenn_poll_log_socket error Traceback (most recent call last): File "D:\XEdu\basenn_code.py", line 16, in <module> generated_train() File "D:\XEdu\basenn_code.py", line 13, in generated_train model.train(epochs=10,lr=0.01,loss='CrossEntropyLoss',metrics=['acc']) File "D:\XEdu\env\lib\site-packages\BaseNN\BaseNN.py", line 657, in train loss = loss_fun(y_pred, batch_y) File "D:\XEdu\env\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "D:\XEdu\env\lib\site-packages\torch\nn\modules\loss.py", line 1047, in forward return F.cross_entropy(input, target, weight=self.weight, File "D:\XEdu\env\lib\site-packages\torch\nn\functional.py", line 2693, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "D:\XEdu\env\lib\site-packages\torch\nn\functional.py", line 2388, in nll_loss ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index) IndexError: Target 2 is out of bounds.
标签:__,loss,XEdu,train,xedu,鸢尾花,yuan,model,size From: https://www.cnblogs.com/flyingsir/p/17903416.html