// Include local CUDA header files. #include #include "include/T5_NN.cuh" void neuralNetworkTests() { /** * Auto-generated from the following PyTorch (v1.12.1+cu113) model: * DNN( * (layers): Sequential( * (0): Linear(in_features=44, out_features=32, bias=True) * (1): ReLU() * (2): Linear(in_features=32, out_features=1, bias=True) * (3): Sigmoid() * ) * ) * * Implements several tests for a simple neural network */ // Test 0 float x_0[44] = { 0.36733299493789672852, 1.91577732563018798828,-0.88309174776077270508,119.77561187744140625000,36.04990386962890625000, 4.50182771682739257812, 2.00000000000000000000, 1.91588580608367919922,-0.89918071031570434570,133.31050109863281250000,40.11907196044921875000, 5.16924238204956054688, 7.00000000000000000000, 1.91707599163055419922,-0.92612725496292114258,156.02049255371093750000,46.89520263671875000000, 4.81657695770263671875, 8.00000000000000000000, 1.98394417762756347656, 1.91707599163055419922,-0.92612725496292114258,156.02049255371093750000,46.89520263671875000000, 4.81657695770263671875, 8.00000000000000000000, 1.91981530189514160156,-0.95805484056472778320,183.20950317382812500000,54.91015243530273437500, 5.12165689468383789062, 9.00000000000000000000, 1.94350647926330566406,-0.98649674654006958008,218.98399353027343750000,64.03046417236328125000, 7.96829080581665039062,10.00000000000000000000, 0.36688947677612304688, 1.91601562500000000000,-0.88330078125000000000, 4.84172344207763671875, 4.86271524429321289062, 6.47157335281372070312 }; std::cout << "Test 0: " << neuralNetwork(x_0) << " (obtained) " << 0.8417555689811707 << " (actual)" << std::endl; // Test 1 float x_1[44] = { -0.02677080780267715454,-0.11133484542369842529, 1.10083162784576416016,-2.45958042144775390625,22.04617309570312500000, 3.89164686203002929688, 1.00000000000000000000,-0.14920698106288909912, 1.19080781936645507812,-5.59125995635986328125,37.33440780639648437500, 4.41842317581176757812, 2.00000000000000000000,-0.16644126176834106445, 1.28536617755889892578,-8.85809993743896484375,52.97566604614257812500, 4.76834058761596679688, 3.00000000000000000000,-0.10660486668348312378,-0.16644126176834106445, 1.28536617755889892578,-8.85809993743896484375,52.97566604614257812500, 4.76834058761596679688, 3.00000000000000000000,-0.18082295358180999756, 1.37787485122680664062,-12.25119972229003906250,67.38456726074218750000, 4.90356302261352539062, 4.00000000000000000000,-0.14431358873844146729, 1.49830913543701171875,-12.25119972229003906250,84.59893798828125000000, 5.13106870651245117188, 5.00000000000000000000,-0.02704885415732860565,-0.14916992187500000000, 1.19042968750000000000, 4.44778537750244140625, 4.39290475845336914062, 4.34542751312255859375 }; std::cout << "Test 1: " << neuralNetwork(x_1) << " (obtained) " << 0.7386350035667419 << " (actual)" << std::endl; // Test 2 float x_2[44] = { 0.43457573652267456055,-2.29343843460083007812, 1.60606634616851806641,-130.15950012207031250000,26.54141235351562500000, 4.80736017227172851562, 7.00000000000000000000,-2.29385709762573242188, 1.62442123889923095703,-156.02049255371093750000,31.80125236511230468750, 4.68200397491455078125, 8.00000000000000000000,-2.29575371742248535156, 1.64471626281738281250,-184.31950378417968750000,37.49671936035156250000, 4.56462717056274414062, 9.00000000000000000000, 0.51415467262268066406,-2.29575371742248535156, 1.64471626281738281250,-184.31950378417968750000,37.49671936035156250000, 4.56462717056274414062, 9.00000000000000000000,-2.29950404167175292969, 1.67218530178070068359,-222.63949584960937500000,45.11928176879882812500, 4.60897302627563476562,10.00000000000000000000,-2.30106163024902343750, 1.70405459403991699219,-267.13049316406250000000,54.04970550537109375000, 4.98222732543945312500,11.00000000000000000000, 0.43321475386619567871,-2.29296875000000000000, 1.62402343750000000000, 4.90804862976074218750, 4.92544031143188476562, 4.99128246307373046875 }; std::cout << "Test 2: " << neuralNetwork(x_2) << " (obtained) " << 0.9632309675216675 << " (actual)" << std::endl; // Test 3 float x_3[44] = { 0.85941803455352783203,-0.43138089776039123535, 1.70924532413482666016,-10.89955043792724609375,24.49968147277832031250, 3.99716782569885253906, 1.00000000000000000000,-0.38724628090858459473, 1.73452758789062500000,-13.83974933624267578125,34.86104202270507812500, 4.34987783432006835938, 2.00000000000000000000,-0.33866226673126220703, 1.77263307571411132812,-17.43375015258789062500,50.50726699829101562500, 4.72062492370605468750, 3.00000000000000000000, 0.86370521783828735352,-0.33866226673126220703, 1.77263307571411132812,-17.43375015258789062500,50.50726699829101562500, 4.72062492370605468750, 3.00000000000000000000,-0.31014949083328247070, 1.81999897956848144531,-22.05089950561523437500,69.97055053710937500000, 4.94122171401977539062, 4.00000000000000000000,-0.31647297739982604980, 1.85468864440917968750,-27.07590103149414062500,84.14353942871093750000, 5.12567138671875000000, 5.00000000000000000000, 0.85969483852386474609,-0.38720703125000000000, 1.73437500000000000000, 5.33452892303466796875, 5.34173583984375000000, 5.33873939514160156250 }; std::cout << "Test 3: " << neuralNetwork(x_3) << " (obtained) " << 0.7367947697639465 << " (actual)" << std::endl; // Test 4 float x_4[44] = { 0.02231931313872337341,-2.36339020729064941406, 0.32870784401893615723,-129.04949951171875000000,24.50426673889160156250, 5.00704526901245117188, 7.00000000000000000000,-2.35454463958740234375, 0.36263409256935119629,-157.13049316406250000000,30.10625457763671875000, 4.29540729522705078125, 8.00000000000000000000,-2.35072088241577148438, 0.39806380867958068848,-187.47050476074218750000,36.05953979492187500000, 4.68996810913085937500, 9.00000000000000000000,-0.06675527989864349365,-2.35072088241577148438, 0.39806380867958068848,-187.47050476074218750000,36.05953979492187500000, 4.68996810913085937500, 9.00000000000000000000,-2.35047388076782226562, 0.43656960129737854004,-222.63949584960937500000,42.83499526977539062500, 4.80924272537231445312,10.00000000000000000000,-2.35162854194641113281, 0.48584333062171936035,-266.02050781250000000000,51.12119293212890625000, 4.95140743255615234375,11.00000000000000000000, 0.02566997706890106201,-2.35546875000000000000, 0.36254882812500000000, 4.50050401687622070312, 4.63533544540405273438, 4.39676141738891601562 }; std::cout << "Test 4: " << neuralNetwork(x_4) << " (obtained) " << 0.9753467440605164 << " (actual)" << std::endl; // Test 5 float x_5[44] = { 0.73165106773376464844,-1.59752440452575683594,-1.02944457530975341797,-92.25808715820312500000,38.94069671630859375000, 4.71012306213378906250, 2.00000000000000000000,-1.61688792705535888672,-1.00949323177337646484,-133.31050109863281250000,55.09980773925781250000, 4.82231187820434570312, 7.00000000000000000000,-1.62276434898376464844,-1.01290977001190185547,-156.02049255371093750000,64.07772827148437500000, 5.23981952667236328125, 8.00000000000000000000, 0.07308512926101684570,-1.62276434898376464844,-1.01290977001190185547,-156.02049255371093750000,64.07772827148437500000, 5.23981952667236328125, 8.00000000000000000000,-1.64912068843841552734,-1.04475247859954833984,-186.07600402832031250000,74.27910614013671875000, 7.46810674667358398438, 9.00000000000000000000,-1.66110754013061523438,-1.04071795940399169922,-220.70300292968750000000,86.97294616699218750000, 6.87796926498413085938,10.00000000000000000000, 0.68350267410278320312,-1.59765625000000000000,-1.02929687500000000000, 5.15833663940429687500, 3.84681749343872070312, 3.94461107254028320312 }; std::cout << "Test 5: " << neuralNetwork(x_5) << " (obtained) " << 0.299185574054718 << " (actual)" << std::endl; // Test 6 float x_6[44] = { 0.28405392169952392578, 1.04246437549591064453,-1.50480926036834716797,31.50815391540527343750,25.37283515930175781250, 4.30606555938720703125, 1.00000000000000000000, 1.08456981182098388672,-1.55878770351409912109,49.38648605346679687500,37.69787979125976562500, 4.43878221511840820312, 2.00000000000000000000, 1.11269724369049072266,-1.63006579875946044922,73.14653778076171875000,53.90545272827148437500, 5.01716232299804687500, 3.00000000000000000000, 3.06892323493957519531, 1.11269724369049072266,-1.63006579875946044922,73.14653778076171875000,53.90545272827148437500, 5.01716232299804687500, 3.00000000000000000000, 1.11478650569915771484,-1.68787848949432373047,90.89459991455078125000,66.81137084960937500000, 4.89502048492431640625, 4.00000000000000000000, 1.14112651348114013672,-1.75318944454193115234,131.91600036621093750000,93.86254882812500000000, 8.22543144226074218750, 7.00000000000000000000, 0.28466552495956420898, 1.08496093750000000000,-1.55859375000000000000, 4.75949954986572265625, 4.74656105041503906250, 7.53476285934448242188 }; std::cout << "Test 6: " << neuralNetwork(x_6) << " (obtained) " << 0.4074368476867676 << " (actual)" << std::endl; // Test 7 float x_7[44] = { 0.19784961640834808350, 1.37689054012298583984,-0.96062737703323364258,45.01960372924804687500,24.26802635192871093750, 4.40294551849365234375, 1.00000000000000000000, 1.36158776283264160156,-1.00013911724090576172,65.68494415283203125000,36.02994537353515625000, 4.76352262496948242188, 2.00000000000000000000, 1.34463632106781005859,-1.07603013515472412109,96.87751007080078125000,54.17968368530273437500, 4.85607004165649414062, 3.00000000000000000000,-0.04430476576089859009, 1.34463632106781005859,-1.07603013515472412109,96.87751007080078125000,54.17968368530273437500, 4.85607004165649414062, 3.00000000000000000000, 1.32423305511474609375,-1.14798581600189208984,133.41499328613281250000,76.38349151611328125000, 8.47164726257324218750, 7.00000000000000000000, 1.31804966926574707031,-1.20779883861541748047,152.58500671386718750000,87.98403167724609375000, 7.55131387710571289062, 8.00000000000000000000, 0.18624392151832580566, 1.36132812500000000000,-1.00000000000000000000, 4.66107797622680664062, 5.36772680282592773438, 4.22774553298950195312 }; std::cout << "Test 7: " << neuralNetwork(x_7) << " (obtained) " << 0.39420410990715027 << " (actual)" << std::endl; // Test 8 float x_8[44] = { 0.29960387945175170898,-1.60897099971771240234, 0.39687028527259826660,-61.23089218139648437500,25.52578163146972656250, 4.75988817214965820312, 1.00000000000000000000,-1.60641753673553466797, 0.34004774689674377441,-92.36799621582031250000,38.61283111572265625000, 4.49833202362060546875, 2.00000000000000000000,-1.60916328430175781250, 0.26640024781227111816,-133.31050109863281250000,55.56256866455078125000, 4.91221904754638671875, 7.00000000000000000000, 0.03206261992454528809,-1.60916328430175781250, 0.26640024781227111816,-133.31050109863281250000,55.56256866455078125000, 4.91221904754638671875, 7.00000000000000000000,-1.57710051536560058594, 0.22721114754676818848,-154.08399963378906250000,66.49683380126953125000, 8.13081741333007812500, 8.00000000000000000000,-1.59618663787841796875, 0.16937747597694396973,-187.57499694824218750000,79.28754425048828125000, 5.21961593627929687500, 9.00000000000000000000, 0.30007898807525634766,-1.60644531250000000000, 0.34008789062500000000, 4.77491283416748046875, 5.31689357757568359375, 4.39906787872314453125 }; std::cout << "Test 8: " << neuralNetwork(x_8) << " (obtained) " << 0.5134389996528625 << " (actual)" << std::endl; // Test 9 float x_9[44] = { 2.43939924240112304688,-1.48037910461425781250,-0.89808827638626098633,-74.31018066406250000000,35.66551971435546875000, 4.58380746841430664062, 2.00000000000000000000,-1.47336304187774658203,-0.95069390535354614258,-108.68819427490234375000,52.57325744628906250000, 5.11205244064331054688, 3.00000000000000000000,-1.46548163890838623047,-0.96902400255203247070,-133.31050109863281250000,65.05075073242187500000, 5.13222694396972656250, 7.00000000000000000000, 0.37459355592727661133,-1.46548163890838623047,-0.96902400255203247070,-133.31050109863281250000,65.05075073242187500000, 5.13222694396972656250, 7.00000000000000000000,-1.46096682548522949219,-0.94019252061843872070,-155.73599243164062500000,76.37650299072265625000, 8.44193840026855468750, 8.00000000000000000000,-1.45572412014007568359,-0.93712168931961059570,-187.57499694824218750000,92.53011322021484375000, 8.13301086425781250000, 9.00000000000000000000, 2.43292140960693359375,-1.48046875000000000000,-0.89794921875000000000, 6.90775537490844726562, 3.80039286613464355469, 4.55124187469482421875 }; std::cout << "Test 9: " << neuralNetwork(x_9) << " (obtained) " << 0.030186673626303673 << " (actual)" << std::endl; // Test 10 float x_10[44] = { 0.49149915575981140137,-1.87438452243804931641, 0.49071708321571350098,-119.28102111816406250000,37.48995971679687500000, 5.04393291473388671875, 2.00000000000000000000,-1.87628686428070068359, 0.47988072037696838379,-129.04949951171875000000,40.47939682006835937500, 4.51265621185302734375, 7.00000000000000000000,-1.88188922405242919922, 0.45037236809730529785,-156.02049255371093750000,48.65304946899414062500, 4.83962106704711914062, 8.00000000000000000000, 0.95856052637100219727,-1.88188922405242919922, 0.45037236809730529785,-156.02049255371093750000,48.65304946899414062500, 4.83962106704711914062, 8.00000000000000000000,-1.88366746902465820312, 0.42137494683265686035,-183.20950317382812500000,57.02529525756835937500, 4.92651605606079101562, 9.00000000000000000000,-1.87917077541351318359, 0.40073695778846740723,-220.70300292968750000000,69.01976776123046875000, 7.44169330596923828125,10.00000000000000000000, 0.49237179756164550781,-1.87402343750000000000, 0.49072265625000000000, 4.96720552444458007812, 5.10897111892700195312, 5.36363697052001953125 }; std::cout << "Test 10: " << neuralNetwork(x_10) << " (obtained) " << 0.891961395740509 << " (actual)" << std::endl; } int main() { neuralNetworkTests(); return 0; }