做项目遇到问题 2 AWS NLP 剽窃RuntimeError: size mismatch, m1: [10 x 3], m2: [2 x 10]检测部署报错

报错 RuntimeError: size mismatch, m1: [10 x 3], m2: [2 x 10]

原因:

train.csv 为100x4    4列  第一列  标签是否剽窃  后三列为取的特征值

输入应该为3,结果定义模型的时候,选择的input_features =2 导致数据结构不匹配引起

 

from sagemaker.pytorch import PyTorch
# your import and estimator code, here
output_path=f"s3://{bucket}/{prefix}"
estimator = PyTorch(entry_point="train.py" ,
                    source_dir="source_pytorch",
                    role=role,
                    train_instance_count=1,
                    train_instance_type="ml.c4.xlarge",
                    sagemaker_session=sagemaker_session,
                    output_path=output_path,
                    framework_version="1.0",
                    hyperparameters={"input_features": 3,"hidden_dim": 10,"output_dim": 1,"epochs": 30}) 

#原来是2 与AWS S3 bucket 中train.csv数据结构不对应

#train.csv内容

0,0.39814814814814814,0.0,0.1917808219178082
1,0.8693693693693694,0.44954128440366975,0.8464912280701754
1,0.5935828877005348,0.08196721311475409,0.3160621761658031
0,0.5445026178010471,0.0,0.24257425742574257
0,0.32950191570881227,0.0,0.16117216117216118
0,0.5903083700440529,0.0,0.30165289256198347
1,0.7597765363128491,0.24571428571428572,0.484304932735426
0,0.5161290322580645,0.0,0.2708333333333333
0,0.44086021505376344,0.0,0.22395833333333334
1,0.9794520547945206,0.7887323943661971,0.9
1,0.9513888888888888,0.5214285714285715,0.8940397350993378
1,0.9764705882352941,0.5783132530120482,0.8232044198895028
1,0.8117647058823529,0.28313253012048195,0.45977011494252873
0,0.4411764705882353,0.0,0.3055555555555556
0,0.4888888888888889,0.0,0.2826086956521739
1,0.813953488372093,0.6341463414634146,0.7888888888888889
0,0.6111111111111112,0.0,0.3246753246753247
1,1.0,0.9659090909090909,1.0
1,0.634020618556701,0.005263157894736842,0.36893203883495146
1,0.5829383886255924,0.08695652173913043,0.4166666666666667
1,0.6379310344827587,0.30701754385964913,0.4898785425101215
0,0.42038216560509556,0.0,0.21875
1,0.6877637130801688,0.07725321888412018,0.5163934426229508
1,0.6766467065868264,0.11042944785276074,0.4725274725274725
1,0.7692307692307693,0.45084745762711864,0.6064516129032258
1,0.7122641509433962,0.08653846153846154,0.536697247706422
1,0.6299212598425197,0.28,0.39436619718309857
1,0.7157360406091371,0.0051813471502590676,0.3431372549019608
0,0.3320610687022901,0.0,0.15302491103202848
1,0.7172131147540983,0.07916666666666666,0.4559386973180077
1,0.8782608695652174,0.47345132743362833,0.82
1,0.5298013245033113,0.31543624161073824,0.45
0,0.5721153846153846,0.0,0.22935779816513763
0,0.319672131147541,0.0,0.16535433070866143
0,0.53,0.0,0.26046511627906976
1,0.78,0.6071428571428571,0.6699029126213593
0,0.6526946107784432,0.0,0.3551912568306011
0,0.4439461883408072,0.0,0.23376623376623376
1,0.6650246305418719,0.18090452261306533,0.3492647058823529
1,0.7281553398058253,0.034653465346534656,0.3476190476190476
1,0.7620481927710844,0.2896341463414634,0.5677233429394812
1,0.9470198675496688,0.2857142857142857,0.774390243902439
1,0.3684210526315789,0.0,0.19298245614035087
0,0.5328947368421053,0.0,0.21818181818181817
0,0.6184971098265896,0.005917159763313609,0.26666666666666666
0,0.5103092783505154,0.010526315789473684,0.22110552763819097
0,0.5798319327731093,0.0,0.2289156626506024
0,0.40703517587939697,0.0,0.1722488038277512
0,0.5154639175257731,0.0,0.23684210526315788
1,0.5845410628019324,0.04926108374384237,0.29493087557603687
1,0.6171875,0.1693548387096774,0.5037593984962406
1,1.0,0.84251968503937,0.9117647058823529
1,0.9916666666666667,0.8879310344827587,0.9923076923076923
0,0.550561797752809,0.0,0.2833333333333333
0,0.41935483870967744,0.0,0.2616822429906542
1,0.8351648351648352,0.034482758620689655,0.6470588235294118
1,0.9270833333333334,0.29347826086956524,0.85
0,0.4928909952606635,0.0,0.2350230414746544
1,0.7087378640776699,0.3217821782178218,0.6619718309859155
1,0.8633879781420765,0.30726256983240224,0.7911111111111111
1,0.9606060606060606,0.8650306748466258,0.9298245614035088
0,0.4380165289256198,0.0,0.2230769230769231
1,0.7336683417085427,0.07179487179487179,0.4900990099009901
1,0.5138888888888888,0.0,0.25203252032520324
0,0.4861111111111111,0.0,0.22767857142857142
1,0.8451882845188284,0.3021276595744681,0.6437246963562753
1,0.485,0.0,0.24271844660194175
1,0.9506726457399103,0.7808219178082192,0.8395061728395061
1,0.551219512195122,0.23383084577114427,0.2830188679245283
0,0.3612565445026178,0.0,0.16176470588235295
 

 

 

你可能感兴趣的:(pytorch,NLP,udacity学城)