diff --git a/.gitignore b/.gitignore index 2269427c1edc001edae94bdf7e9fce0e53fad2d8..988c81eb83b80be97164153692a1b51b5c4c55a1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pdf .data/ -*.pyc \ No newline at end of file +*.pyc +colab_copy.ipynb diff --git a/.history/attention.csv b/.history/attention.csv new file mode 100755 index 0000000000000000000000000000000000000000..a4fd10459c9dc52a9851f17081ffdee6756a7267 --- /dev/null +++ b/.history/attention.csv @@ -0,0 +1,21 @@ +loss,categorical_crossentropy,categorical_accuracy,categorical_hinge,val_loss,val_categorical_crossentropy,val_categorical_accuracy,val_categorical_hinge +0.6585725545883179,0.6585682034492493,0.7642568349838257,0.5678364634513855,0.2568819522857666,0.2569003105163574,0.9455353617668152,0.22106097638607025 +0.3117441236972809,0.31175822019577026,0.9260188341140747,0.28718841075897217,0.20644637942314148,0.20646549761295319,0.9583955407142639,0.21028545498847961 +0.2320394515991211,0.23205384612083435,0.9526039361953735,0.21906721591949463,0.19976148009300232,0.19977888464927673,0.9600058197975159,0.19350706040859222 +0.21258755028247833,0.21259839832782745,0.9577119946479797,0.20466887950897217,0.19828014075756073,0.19829769432544708,0.9600641131401062,0.19444385170936584 +0.2191668599843979,0.21918070316314697,0.9557140469551086,0.21299272775650024,0.1973971724510193,0.19741465151309967,0.9601370096206665,0.1945493221282959 +0.22623170912265778,0.2262469381093979,0.9496357440948486,0.22568148374557495,0.22122713923454285,0.2212470918893814,0.9571059346199036,0.20895777642726898 +0.2022058069705963,0.20221897959709167,0.9580804705619812,0.20320773124694824,0.19595696032047272,0.1959744542837143,0.9601370096206665,0.1926230937242508 +0.20679694414138794,0.20681001245975494,0.9581447243690491,0.20231115818023682,0.1971341073513031,0.19715237617492676,0.9601296782493591,0.1978731006383896 +0.200638085603714,0.2006513774394989,0.9586011171340942,0.20150400698184967,0.19585992395877838,0.1958770900964737,0.9601370096206665,0.19168958067893982 +0.19817732274532318,0.1981901228427887,0.95919269323349,0.19827494025230408,0.19505365192890167,0.19507072865962982,0.9601370096206665,0.19158127903938293 +0.21982578933238983,0.21984072029590607,0.9528202414512634,0.21658064424991608,0.19459141790866852,0.19460846483707428,0.9601370096206665,0.19168177247047424 +0.20578214526176453,0.20579560101032257,0.9576444029808044,0.20405413210391998,0.1948329210281372,0.19485007226467133,0.9601370096206665,0.19221912324428558 +0.19905276596546173,0.19906280934810638,0.958895206451416,0.19894179701805115,0.19444401562213898,0.19446124136447906,0.9601370096206665,0.19095449149608612 +0.20114865899085999,0.20116181671619415,0.9576274752616882,0.2009626030921936,0.19463831186294556,0.19465532898902893,0.9601370096206665,0.1908532977104187 +0.1964700073003769,0.19648253917694092,0.9596186876296997,0.19647063314914703,0.19445690512657166,0.19447395205497742,0.9601370096206665,0.1904924362897873 +0.19587695598602295,0.19588960707187653,0.9597403407096863,0.19600547850131989,0.1942262500524521,0.19424325227737427,0.9601370096206665,0.19055908918380737 +0.2118632197380066,0.21187663078308105,0.9585402607917786,0.2008778303861618,0.19513902068138123,0.19515620172023773,0.9601370096206665,0.19171009957790375 +0.19799818098545074,0.1980057805776596,0.9585673213005066,0.1985451579093933,0.1943429857492447,0.19436006247997284,0.9601370096206665,0.1902288943529129 +0.19693350791931152,0.19694645702838898,0.958922266960144,0.19714725017547607,0.194101944565773,0.194118931889534,0.9601370096206665,0.1902865618467331 +0.2059560865163803,0.20596808195114136,0.9587802886962891,0.1938168853521347,0.21157428622245789,0.21159103512763977,0.9601370096206665,0.18894413113594055 diff --git a/.history/baseline.csv b/.history/baseline.csv new file mode 100755 index 0000000000000000000000000000000000000000..868e84b83df19e69b7d76a0478ec6ce30b93ecd6 --- /dev/null +++ b/.history/baseline.csv @@ -0,0 +1,19 @@ +loss,categorical_crossentropy,categorical_accuracy,categorical_hinge,val_loss,val_categorical_crossentropy,val_categorical_accuracy,val_categorical_hinge +4.089780330657959,4.089889049530029,0.6349388360977173,4.385586738586426,0.6959022283554077,0.6959721446037292,0.8305895924568176,0.7968767285346985 +1.446198582649231,1.4461439847946167,0.8774309754371643,1.5515626668930054,0.32732632756233215,0.32736486196517944,0.9553061127662659,0.37597230076789856 +0.682375431060791,0.682311475276947,0.9188065528869629,0.7650437951087952,0.3034522533416748,0.3034909665584564,0.9526150226593018,0.40639927983283997 +0.29129651188850403,0.2912536859512329,0.9471720457077026,0.6299078464508057,0.2139475792646408,0.21396099030971527,0.959001898765564,1.0784140825271606 +0.22273649275302887,0.2227565348148346,0.9553127288818359,1.5920904874801636,0.20081201195716858,0.20083437860012054,0.9594038128852844,1.8987538814544678 +0.2146245390176773,0.21464309096336365,0.9559412598609924,1.0274194478988647,0.2028401643037796,0.2028619945049286,0.9593607187271118,1.131609559059143 +0.20366843044757843,0.20368562638759613,0.9579789042472839,0.7655198574066162,0.1954556703567505,0.19547241926193237,0.9594038128852844,1.254904866218567 +0.19993343949317932,0.1999497413635254,0.959175169467926,0.5612305998802185,0.2006416916847229,0.20066288113594055,0.9594038128852844,0.7482663989067078 +0.20094075798988342,0.20095765590667725,0.9583979845046997,0.43938910961151123,0.19446147978305817,0.19448037445545197,0.9593320488929749,0.49432244896888733 +0.1993952989578247,0.1994120329618454,0.9586581587791443,0.39073625206947327,0.19673840701580048,0.1967582106590271,0.9592818021774292,0.5321310758590698 +0.19984625279903412,0.19986273348331451,0.9586615562438965,0.5178192257881165,0.19690574705600739,0.19692611694335938,0.9592387676239014,0.6515073776245117 +0.20708803832530975,0.20710566639900208,0.9576646685600281,0.5113606452941895,0.1945960521697998,0.19461435079574585,0.9592100381851196,0.6649221777915955 +0.20578958094120026,0.20580680668354034,0.9576680660247803,0.4058030843734741,0.19368377327919006,0.19370156526565552,0.9592459201812744,0.4930337965488434 +0.20253966748714447,0.20255622267723083,0.9577085971832275,0.3992466926574707,0.19528517127037048,0.19530461728572845,0.9591813087463379,0.5414166450500488 +0.19839921593666077,0.1984151005744934,0.9587358832359314,0.353200227022171,0.194997638463974,0.19501681625843048,0.9591813087463379,0.5189060568809509 +0.20598508417606354,0.2060023695230484,0.9578572511672974,0.32146432995796204,0.19377873837947845,0.19379615783691406,0.9591741561889648,0.4748823642730713 +0.20394311845302582,0.2039605677127838,0.9582594037055969,0.2595149874687195,0.19378499686717987,0.19380225241184235,0.9591956734657288,0.35871943831443787 +0.20424002408981323,0.20425696671009064,0.9580769538879395,0.25057151913642883,0.19378751516342163,0.19380584359169006,0.9591813087463379,0.3638860881328583 diff --git a/.history/baseline_prev.csv b/.history/baseline_prev.csv new file mode 100644 index 0000000000000000000000000000000000000000..00f38e142f7f9417b566642f5135f2510edb2b73 --- /dev/null +++ b/.history/baseline_prev.csv @@ -0,0 +1,2 @@ +loss,categorical_crossentropy,categorical_accuracy,categorical_hinge,val_loss,val_categorical_crossentropy,val_categorical_accuracy,val_categorical_hinge +6.583230018615723,6.58325719833374,0.5245358347892761,6.979791164398193,1.1657143831253052,1.1657381057739258,0.7364387512207031,1.334243655204773 diff --git a/.history/gru.csv b/.history/gru.csv new file mode 100755 index 0000000000000000000000000000000000000000..ffc90be47ef76f7609508a44efa99afc3f836adc --- /dev/null +++ b/.history/gru.csv @@ -0,0 +1,20 @@ +loss,categorical_crossentropy,categorical_accuracy,categorical_hinge,val_loss,val_categorical_crossentropy,val_categorical_accuracy,val_categorical_hinge +0.7226986885070801,0.7226975560188293,0.704392671585083,0.6647999882698059,0.24512435495853424,0.2451450526714325,0.9465906023979187,0.2080182433128357 +0.2418966442346573,0.24186287820339203,0.9466025829315186,0.22906440496444702,0.20266616344451904,0.20268622040748596,0.9604395627975464,0.19118350744247437 +0.21796290576457977,0.21797987818717957,0.9531471133232117,0.21524855494499207,0.19396542012691498,0.1939847618341446,0.9604253768920898,0.1877472847700119 +0.2041829526424408,0.20419970154762268,0.9569871425628662,0.2017723172903061,0.1939530074596405,0.19397211074829102,0.9603615403175354,0.18708907067775726 +0.20949509739875793,0.20951133966445923,0.9546253085136414,0.20763704180717468,0.19192494451999664,0.19194285571575165,0.960404098033905,0.18184705078601837 +0.20149734616279602,0.20151397585868835,0.9568964242935181,0.20037424564361572,0.18975114822387695,0.1897674947977066,0.9603047966957092,0.17709580063819885 +0.1988774538040161,0.19889329373836517,0.9575145840644836,0.19945834577083588,0.1894351840019226,0.18945203721523285,0.9603473544120789,0.1826242357492447 +0.1978028118610382,0.19781842827796936,0.9570980072021484,0.19709548354148865,0.1900397390127182,0.19005511701107025,0.9604253768920898,0.18023012578487396 +0.19413603842258453,0.19415204226970673,0.9587408304214478,0.19253963232040405,0.18731456995010376,0.18733063340187073,0.9603686332702637,0.17768457531929016 +0.1983860284090042,0.19840291142463684,0.9579177498817444,0.19871357083320618,0.1888211965560913,0.18883788585662842,0.9603615403175354,0.17458374798297882 +0.19423127174377441,0.1942470818758011,0.9585022926330566,0.19376978278160095,0.18771056830883026,0.18772709369659424,0.9603544473648071,0.17700858414173126 +0.19282810389995575,0.19284437596797943,0.9587072134017944,0.19153735041618347,0.18702368438243866,0.18703937530517578,0.9604395627975464,0.17744596302509308 +0.1931377351284027,0.19315384328365326,0.9585090279579163,0.19253388047218323,0.18788008391857147,0.18789534270763397,0.9604324698448181,0.1781308650970459 +0.19740456342697144,0.19742043316364288,0.9572727084159851,0.1972353309392929,0.186688631772995,0.18670520186424255,0.9604538083076477,0.18041568994522095 +0.20049788057804108,0.2005147784948349,0.9553711414337158,0.19980721175670624,0.18947020173072815,0.18948468565940857,0.9603757262229919,0.17599371075630188 +0.1905730962753296,0.19058921933174133,0.9590028524398804,0.19003361463546753,0.187227264046669,0.1872435212135315,0.9604538083076477,0.17640019953250885 +0.1920197755098343,0.19203472137451172,0.9584922194480896,0.19177106022834778,0.19291670620441437,0.19293312728405,0.9601274132728577,0.17808152735233307 +0.19442370533943176,0.19443930685520172,0.9577967524528503,0.19535745680332184,0.18815527856349945,0.18817181885242462,0.9601203203201294,0.17747144401073456 +0.1930849701166153,0.1931002289056778,0.9583612084388733,0.19231447577476501,0.1886867880821228,0.1887015551328659,0.9602835178375244,0.17552784085273743 diff --git a/.history/lstm.csv b/.history/lstm.csv new file mode 100755 index 0000000000000000000000000000000000000000..faf23f3f52029a3db0cdb582db606a0e6f27a55c --- /dev/null +++ b/.history/lstm.csv @@ -0,0 +1,21 @@ +loss,categorical_crossentropy,categorical_accuracy,categorical_hinge,val_loss,val_categorical_crossentropy,val_categorical_accuracy,val_categorical_hinge +0.6616435647010803,0.6616473197937012,0.7678285837173462,0.5768730640411377,0.21920111775398254,0.21921661496162415,0.9578118920326233,0.19979453086853027 +0.2124859094619751,0.21249748766422272,0.9572364687919617,0.2017192840576172,0.1961805522441864,0.1961977630853653,0.9605434536933899,0.1899353563785553 +0.2013033926486969,0.20132088661193848,0.958790123462677,0.19853036105632782,0.19342073798179626,0.19343769550323486,0.9605434536933899,0.18548347055912018 +0.1994745135307312,0.19949133694171906,0.9584220051765442,0.19914424419403076,0.19325415790081024,0.19327090680599213,0.9605434536933899,0.1858225017786026 +0.19818609952926636,0.19820430874824524,0.9595028162002563,0.19542698562145233,0.19724640250205994,0.19726401567459106,0.9605434536933899,0.1885501891374588 +0.19698849320411682,0.19700615108013153,0.9596278071403503,0.19604097306728363,0.19273510575294495,0.1927519291639328,0.9605434536933899,0.1855636090040207 +0.19459326565265656,0.19461138546466827,0.9597190022468567,0.1934642195701599,0.19132129848003387,0.19133780896663666,0.9605434536933899,0.1812693029642105 +0.19469085335731506,0.19470927119255066,0.9595433473587036,0.19427575170993805,0.19076292216777802,0.1907796412706375,0.9605434536933899,0.1826714128255844 +0.1941087543964386,0.1941264271736145,0.9595500826835632,0.19388775527477264,0.19234132766723633,0.19235816597938538,0.9605362415313721,0.18606065213680267 +0.19580835103988647,0.19582629203796387,0.9593643546104431,0.1948489397764206,0.19710120558738708,0.19711589813232422,0.9605362415313721,0.1799246221780777 +0.19451528787612915,0.19453303515911102,0.9596244096755981,0.19350221753120422,0.1927262842655182,0.19274340569972992,0.9604212045669556,0.18662592768669128 +0.19287285208702087,0.19288931787014008,0.9596379399299622,0.19153670966625214,0.18834100663661957,0.18835720419883728,0.9605434536933899,0.18142221868038177 +0.19426625967025757,0.19428321719169617,0.9588881134986877,0.1948876827955246,0.19082169234752655,0.19083724915981293,0.9605434536933899,0.1792384535074234 +0.1905604600906372,0.19057735800743103,0.9597696661949158,0.18989630043506622,0.1873527616262436,0.18736828863620758,0.9605434536933899,0.1793559044599533 +0.18944881856441498,0.18946509063243866,0.9597156047821045,0.18928691744804382,0.18695604801177979,0.18697185814380646,0.9605434536933899,0.1805138736963272 +0.18847715854644775,0.18849286437034607,0.9597324728965759,0.18832366168498993,0.18704544007778168,0.1870613843202591,0.9605434536933899,0.18155622482299805 +0.1882047802209854,0.18822067975997925,0.9596784710884094,0.1883043646812439,0.18660461902618408,0.18662020564079285,0.9605434536933899,0.17966781556606293 +0.18845705687999725,0.18847285211086273,0.9596615433692932,0.18891288340091705,0.1865667849779129,0.18658317625522614,0.9605362415313721,0.18284381926059723 +0.1882510781288147,0.18826723098754883,0.9595771431922913,0.18828585743904114,0.18645426630973816,0.18647007644176483,0.9605434536933899,0.18196777999401093 +0.18761856853961945,0.18763436377048492,0.9596311450004578,0.18795886635780334,0.1865798830986023,0.18659621477127075,0.9605434536933899,0.1813698559999466 diff --git a/.model/attention/keras_metadata.pb b/.model/attention/keras_metadata.pb new file mode 100755 index 0000000000000000000000000000000000000000..a85a548eb098711de803bb25c8e4aac7f2e3d7e9 --- /dev/null +++ b/.model/attention/keras_metadata.pb @@ -0,0 +1,15 @@ + +‘root"_tf_keras_sequential*ì{"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "Attention", "config": {"name": "attention", "trainable": true, "dtype": "float32", "units": 16}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 5, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "Attention", "config": {"name": "attention", "trainable": true, "dtype": "float32", "units": 16}, "shared_object_id": 1}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 4}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 7}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 8}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 9}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 10}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +µroot.layer_with_weights-0"_tf_keras_layer*þ{"name": "attention", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Attention", "config": {"name": "attention", "trainable": true, "dtype": "float32", "units": 16}, "shared_object_id": 1, "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +Âroot.layer_with_weights-1"_tf_keras_layer*‹{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 4, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 16}}, "shared_object_id": 11}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 16]}}2 +ø-root.layer_with_weights-0.attention_score_vec"_tf_keras_layer*{"name": "attention_score_vec", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "attention_score_vec", "trainable": true, "dtype": "float32", "units": 7, "activation": "linear", "use_bias": false, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 12}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 13}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 14, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 7}}, "shared_object_id": 15}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +· root.layer_with_weights-0.h_t"_tf_keras_layer*ü{"name": "last_hidden_state", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Lambda", "config": {"name": "last_hidden_state", "trainable": true, "dtype": "float32", "function": {"class_name": "__tuple__", "items": ["4wEAAAAAAAAAAAAAAAEAAAAFAAAAUwAAAHMWAAAAfABkAGQAhQJkAWQAZACFAmYDGQBTACkCTun/\n////qQApAdoBeHICAAAAcgIAAAD6MS9ob21lL250b3AvUHljaGFybVByb2plY3RzL2ZpbmFsX2xh\nYi9hdHRlbnRpb24ucHnaCDxsYW1iZGE+GwAAAHMCAAAAFgA=\n", null, null]}, "function_type": "lambda", "module": "attention", "output_shape": {"class_name": "__tuple__", "items": [7]}, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "shared_object_id": 16}2 +™)root.layer_with_weights-0.attention_score"_tf_keras_layer*Ò{"name": "attention_score", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dot", "config": {"name": "attention_score", "trainable": true, "dtype": "float32", "axes": [1, 2], "normalize": false}, "shared_object_id": 17, "build_input_shape": [{"class_name": "TensorShape", "items": [null, 7]}, {"class_name": "TensorShape", "items": [null, 10, 7]}]}2 +—*root.layer_with_weights-0.attention_weight"_tf_keras_layer*Ï{"name": "attention_weight", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Activation", "config": {"name": "attention_weight", "trainable": true, "dtype": "float32", "activation": "softmax"}, "shared_object_id": 18}2 +—(root.layer_with_weights-0.context_vector"_tf_keras_layer*Ñ{"name": "context_vector", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dot", "config": {"name": "context_vector", "trainable": true, "dtype": "float32", "axes": [1, 1], "normalize": false}, "shared_object_id": 19, "build_input_shape": [{"class_name": "TensorShape", "items": [null, 10, 7]}, {"class_name": "TensorShape", "items": [null, 10]}]}2 +ˆ*root.layer_with_weights-0.attention_output"_tf_keras_layer*À{"name": "attention_output", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Concatenate", "config": {"name": "attention_output", "trainable": true, "dtype": "float32", "axis": -1}, "shared_object_id": 20, "build_input_shape": [{"class_name": "TensorShape", "items": [null, 7]}, {"class_name": "TensorShape", "items": [null, 7]}]}2 +ì*root.layer_with_weights-0.attention_vector"_tf_keras_layer*¤{"name": "attention_vector", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "attention_vector", "trainable": true, "dtype": "float32", "units": 16, "activation": "tanh", "use_bias": false, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 21}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 22}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 23, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 14}}, "shared_object_id": 24}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 14]}}2 +¹droot.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 25}2 +žeroot.keras_api.metrics.1"_tf_keras_metric*ç{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 8}2 +çfroot.keras_api.metrics.2"_tf_keras_metric*°{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 9}2 +ßgroot.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 10}2 \ No newline at end of file diff --git a/.model/attention/saved_model.pb b/.model/attention/saved_model.pb new file mode 100755 index 0000000000000000000000000000000000000000..573c7f905e81021bac35246e9f179dff9cdde29c Binary files /dev/null and b/.model/attention/saved_model.pb differ diff --git a/.model/attention/variables/variables.data-00000-of-00001 b/.model/attention/variables/variables.data-00000-of-00001 new file mode 100755 index 0000000000000000000000000000000000000000..1a5c7b2d5f137e1a1170e292ea9a9f2f47e7e253 Binary files /dev/null and b/.model/attention/variables/variables.data-00000-of-00001 differ diff --git a/.model/attention/variables/variables.index b/.model/attention/variables/variables.index new file mode 100755 index 0000000000000000000000000000000000000000..a31867933f61483597b04caaeebd956bbc4d30f3 Binary files /dev/null and b/.model/attention/variables/variables.index differ diff --git a/.model/attention_old/keras_metadata.pb b/.model/attention_old/keras_metadata.pb new file mode 100755 index 0000000000000000000000000000000000000000..a85a548eb098711de803bb25c8e4aac7f2e3d7e9 --- /dev/null +++ b/.model/attention_old/keras_metadata.pb @@ -0,0 +1,15 @@ + +‘root"_tf_keras_sequential*ì{"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "Attention", "config": {"name": "attention", "trainable": true, "dtype": "float32", "units": 16}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 5, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "Attention", "config": {"name": "attention", "trainable": true, "dtype": "float32", "units": 16}, "shared_object_id": 1}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 4}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 7}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 8}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 9}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 10}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +µroot.layer_with_weights-0"_tf_keras_layer*þ{"name": "attention", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Attention", "config": {"name": "attention", "trainable": true, "dtype": "float32", "units": 16}, "shared_object_id": 1, "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +Âroot.layer_with_weights-1"_tf_keras_layer*‹{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 4, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 16}}, "shared_object_id": 11}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 16]}}2 +ø-root.layer_with_weights-0.attention_score_vec"_tf_keras_layer*{"name": "attention_score_vec", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "attention_score_vec", "trainable": true, "dtype": "float32", "units": 7, "activation": "linear", "use_bias": false, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 12}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 13}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 14, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 7}}, "shared_object_id": 15}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +· root.layer_with_weights-0.h_t"_tf_keras_layer*ü{"name": "last_hidden_state", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Lambda", "config": {"name": "last_hidden_state", "trainable": true, "dtype": "float32", "function": {"class_name": "__tuple__", "items": ["4wEAAAAAAAAAAAAAAAEAAAAFAAAAUwAAAHMWAAAAfABkAGQAhQJkAWQAZACFAmYDGQBTACkCTun/\n////qQApAdoBeHICAAAAcgIAAAD6MS9ob21lL250b3AvUHljaGFybVByb2plY3RzL2ZpbmFsX2xh\nYi9hdHRlbnRpb24ucHnaCDxsYW1iZGE+GwAAAHMCAAAAFgA=\n", null, null]}, "function_type": "lambda", "module": "attention", "output_shape": {"class_name": "__tuple__", "items": [7]}, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "shared_object_id": 16}2 +™)root.layer_with_weights-0.attention_score"_tf_keras_layer*Ò{"name": "attention_score", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dot", "config": {"name": "attention_score", "trainable": true, "dtype": "float32", "axes": [1, 2], "normalize": false}, "shared_object_id": 17, "build_input_shape": [{"class_name": "TensorShape", "items": [null, 7]}, {"class_name": "TensorShape", "items": [null, 10, 7]}]}2 +—*root.layer_with_weights-0.attention_weight"_tf_keras_layer*Ï{"name": "attention_weight", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Activation", "config": {"name": "attention_weight", "trainable": true, "dtype": "float32", "activation": "softmax"}, "shared_object_id": 18}2 +—(root.layer_with_weights-0.context_vector"_tf_keras_layer*Ñ{"name": "context_vector", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dot", "config": {"name": "context_vector", "trainable": true, "dtype": "float32", "axes": [1, 1], "normalize": false}, "shared_object_id": 19, "build_input_shape": [{"class_name": "TensorShape", "items": [null, 10, 7]}, {"class_name": "TensorShape", "items": [null, 10]}]}2 +ˆ*root.layer_with_weights-0.attention_output"_tf_keras_layer*À{"name": "attention_output", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Concatenate", "config": {"name": "attention_output", "trainable": true, "dtype": "float32", "axis": -1}, "shared_object_id": 20, "build_input_shape": [{"class_name": "TensorShape", "items": [null, 7]}, {"class_name": "TensorShape", "items": [null, 7]}]}2 +ì*root.layer_with_weights-0.attention_vector"_tf_keras_layer*¤{"name": "attention_vector", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "attention_vector", "trainable": true, "dtype": "float32", "units": 16, "activation": "tanh", "use_bias": false, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 21}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 22}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 23, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 14}}, "shared_object_id": 24}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 14]}}2 +¹droot.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 25}2 +žeroot.keras_api.metrics.1"_tf_keras_metric*ç{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 8}2 +çfroot.keras_api.metrics.2"_tf_keras_metric*°{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 9}2 +ßgroot.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 10}2 \ No newline at end of file diff --git a/.model/attention_old/saved_model.pb b/.model/attention_old/saved_model.pb new file mode 100755 index 0000000000000000000000000000000000000000..fd14556a39adbd0b19cd57320afb36614c28e41d Binary files /dev/null and b/.model/attention_old/saved_model.pb differ diff --git a/.model/attention_old/variables/variables.data-00000-of-00001 b/.model/attention_old/variables/variables.data-00000-of-00001 new file mode 100755 index 0000000000000000000000000000000000000000..11fc631f30276cf65cf88af4fb73eed3a7c0b823 Binary files /dev/null and b/.model/attention_old/variables/variables.data-00000-of-00001 differ diff --git a/.model/attention_old/variables/variables.index b/.model/attention_old/variables/variables.index new file mode 100755 index 0000000000000000000000000000000000000000..d391c8cfa1213eda737a8ed1cc98b5073374074b Binary files /dev/null and b/.model/attention_old/variables/variables.index differ diff --git a/.model/baseline/keras_metadata.pb b/.model/baseline/keras_metadata.pb new file mode 100755 index 0000000000000000000000000000000000000000..f5bbc8ad4039df2c853242b4325c9b768c3998e8 --- /dev/null +++ b/.model/baseline/keras_metadata.pb @@ -0,0 +1,9 @@ + +Ë#root"_tf_keras_sequential*¦#{"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 16, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Flatten", "config": {"name": "flatten", "trainable": true, "dtype": "float32", "data_format": "channels_last"}}, {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 8, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 16, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 2}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 3}, {"class_name": "Flatten", "config": {"name": "flatten", "trainable": true, "dtype": "float32", "data_format": "channels_last"}, "shared_object_id": 4}, {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 5}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 6}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 7}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 10}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 11}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 12}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 13}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +Åroot.layer_with_weights-0"_tf_keras_layer*Ž{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 16, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 2}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 3, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 7}}, "shared_object_id": 14}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +’root.layer-1"_tf_keras_layer*è{"name": "flatten", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Flatten", "config": {"name": "flatten", "trainable": true, "dtype": "float32", "data_format": "channels_last"}, "shared_object_id": 4, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 1, "axes": {}}, "shared_object_id": 15}}2 +Èroot.layer_with_weights-1"_tf_keras_layer*‘{"name": "dense_1", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 5}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 6}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 7, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 160}}, "shared_object_id": 16}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 160]}}2 +¹=root.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 17}2 +Ÿ>root.keras_api.metrics.1"_tf_keras_metric*è{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 11}2 +è?root.keras_api.metrics.2"_tf_keras_metric*±{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 12}2 +ß@root.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 13}2 \ No newline at end of file diff --git a/.model/baseline/saved_model.pb b/.model/baseline/saved_model.pb new file mode 100755 index 0000000000000000000000000000000000000000..d696b19b07aab19165ab8f4e0b3bf200e635c6e7 Binary files /dev/null and b/.model/baseline/saved_model.pb differ diff --git a/.model/baseline/variables/variables.data-00000-of-00001 b/.model/baseline/variables/variables.data-00000-of-00001 new file mode 100755 index 0000000000000000000000000000000000000000..4ab18dcf4968fd05683e51d344e93d6be682a6d2 Binary files /dev/null and b/.model/baseline/variables/variables.data-00000-of-00001 differ diff --git a/.model/baseline/variables/variables.index b/.model/baseline/variables/variables.index new file mode 100755 index 0000000000000000000000000000000000000000..3c46f49202f653795f193e491ec78e45d9c6310c Binary files /dev/null and b/.model/baseline/variables/variables.index differ diff --git a/.model/baseline_old/keras_metadata.pb b/.model/baseline_old/keras_metadata.pb new file mode 100644 index 0000000000000000000000000000000000000000..f5bbc8ad4039df2c853242b4325c9b768c3998e8 --- /dev/null +++ b/.model/baseline_old/keras_metadata.pb @@ -0,0 +1,9 @@ + +Ë#root"_tf_keras_sequential*¦#{"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 16, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}, {"class_name": "Flatten", "config": {"name": "flatten", "trainable": true, "dtype": "float32", "data_format": "channels_last"}}, {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 8, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 16, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 2}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 3}, {"class_name": "Flatten", "config": {"name": "flatten", "trainable": true, "dtype": "float32", "data_format": "channels_last"}, "shared_object_id": 4}, {"class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 5}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 6}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 7}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 10}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 11}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 12}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 13}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +Åroot.layer_with_weights-0"_tf_keras_layer*Ž{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 16, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 2}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 3, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 7}}, "shared_object_id": 14}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +’root.layer-1"_tf_keras_layer*è{"name": "flatten", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Flatten", "config": {"name": "flatten", "trainable": true, "dtype": "float32", "data_format": "channels_last"}, "shared_object_id": 4, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 1, "axes": {}}, "shared_object_id": 15}}2 +Èroot.layer_with_weights-1"_tf_keras_layer*‘{"name": "dense_1", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense_1", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 5}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 6}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 7, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 160}}, "shared_object_id": 16}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 160]}}2 +¹=root.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 17}2 +Ÿ>root.keras_api.metrics.1"_tf_keras_metric*è{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 11}2 +è?root.keras_api.metrics.2"_tf_keras_metric*±{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 12}2 +ß@root.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 13}2 \ No newline at end of file diff --git a/.model/baseline_old/saved_model.pb b/.model/baseline_old/saved_model.pb new file mode 100644 index 0000000000000000000000000000000000000000..314b807266c126e68eaa9ca9619db4051c08a18f Binary files /dev/null and b/.model/baseline_old/saved_model.pb differ diff --git a/.model/baseline_old/variables/variables.data-00000-of-00001 b/.model/baseline_old/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000000000000000000000000000000000000..194bf61b1b64d0f8946548c1097f540c0b17d335 Binary files /dev/null and b/.model/baseline_old/variables/variables.data-00000-of-00001 differ diff --git a/.model/baseline_old/variables/variables.index b/.model/baseline_old/variables/variables.index new file mode 100644 index 0000000000000000000000000000000000000000..0961630994c1bd991f3a9c2fc268c85ea89e5109 Binary files /dev/null and b/.model/baseline_old/variables/variables.index differ diff --git a/.model/gru/keras_metadata.pb b/.model/gru/keras_metadata.pb new file mode 100755 index 0000000000000000000000000000000000000000..38cf9a65767f19a017a142115d02a1c5d7b27048 --- /dev/null +++ b/.model/gru/keras_metadata.pb @@ -0,0 +1,10 @@ + +¦(root"_tf_keras_sequential*({"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "GRU", "config": {"name": "gru", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 9, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "GRU", "config": {"name": "gru", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}, "shared_object_id": 5}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 11}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +—root.layer_with_weights-0"_tf_keras_rnn_layer*Ü +{"name": "gru", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "GRU", "config": {"name": "gru", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}, "shared_object_id": 5, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, null, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}, "shared_object_id": 15}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +Âroot.layer_with_weights-1"_tf_keras_layer*‹{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 16}}, "shared_object_id": 16}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 16]}}2 +ßroot.layer_with_weights-0.cell"_tf_keras_layer*£{"name": "gru_cell", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "GRUCell", "config": {"name": "gru_cell", "trainable": true, "dtype": "float32", "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}, "shared_object_id": 4}2 +¹=root.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 17}2 +Ÿ>root.keras_api.metrics.1"_tf_keras_metric*è{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}2 +è?root.keras_api.metrics.2"_tf_keras_metric*±{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}2 +ß@root.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}2 \ No newline at end of file diff --git a/.model/gru/saved_model.pb b/.model/gru/saved_model.pb new file mode 100755 index 0000000000000000000000000000000000000000..36abe163bc2a1322df2ec0cc62842f932c62d5e2 Binary files /dev/null and b/.model/gru/saved_model.pb differ diff --git a/.model/gru/variables/variables.data-00000-of-00001 b/.model/gru/variables/variables.data-00000-of-00001 new file mode 100755 index 0000000000000000000000000000000000000000..599d90cd6f1435d8ab2141ae6cc5ad25f9258a2b Binary files /dev/null and b/.model/gru/variables/variables.data-00000-of-00001 differ diff --git a/.model/gru/variables/variables.index b/.model/gru/variables/variables.index new file mode 100755 index 0000000000000000000000000000000000000000..ad93e37d8536708d813d20376e267e1baa6fa05c Binary files /dev/null and b/.model/gru/variables/variables.index differ diff --git a/.model/gru_old/keras_metadata.pb b/.model/gru_old/keras_metadata.pb new file mode 100755 index 0000000000000000000000000000000000000000..38cf9a65767f19a017a142115d02a1c5d7b27048 --- /dev/null +++ b/.model/gru_old/keras_metadata.pb @@ -0,0 +1,10 @@ + +¦(root"_tf_keras_sequential*({"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "GRU", "config": {"name": "gru", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 9, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "GRU", "config": {"name": "gru", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}, "shared_object_id": 5}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 11}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +—root.layer_with_weights-0"_tf_keras_rnn_layer*Ü +{"name": "gru", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "GRU", "config": {"name": "gru", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}, "shared_object_id": 5, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, null, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}, "shared_object_id": 15}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +Âroot.layer_with_weights-1"_tf_keras_layer*‹{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 16}}, "shared_object_id": 16}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 16]}}2 +ßroot.layer_with_weights-0.cell"_tf_keras_layer*£{"name": "gru_cell", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "GRUCell", "config": {"name": "gru_cell", "trainable": true, "dtype": "float32", "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2, "reset_after": true}, "shared_object_id": 4}2 +¹=root.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 17}2 +Ÿ>root.keras_api.metrics.1"_tf_keras_metric*è{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}2 +è?root.keras_api.metrics.2"_tf_keras_metric*±{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}2 +ß@root.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}2 \ No newline at end of file diff --git a/.model/gru_old/saved_model.pb b/.model/gru_old/saved_model.pb new file mode 100755 index 0000000000000000000000000000000000000000..92be9c558e0c7b4d81bdf8854f81deb2a9729253 Binary files /dev/null and b/.model/gru_old/saved_model.pb differ diff --git a/.model/gru_old/variables/variables.data-00000-of-00001 b/.model/gru_old/variables/variables.data-00000-of-00001 new file mode 100755 index 0000000000000000000000000000000000000000..e74fb02875e6ff47ea177bc84a80a347125dfd97 Binary files /dev/null and b/.model/gru_old/variables/variables.data-00000-of-00001 differ diff --git a/.model/gru_old/variables/variables.index b/.model/gru_old/variables/variables.index new file mode 100755 index 0000000000000000000000000000000000000000..d43683f808671819f78360cf8b00902d9d3383df Binary files /dev/null and b/.model/gru_old/variables/variables.index differ diff --git a/.model/lstm/keras_metadata.pb b/.model/lstm/keras_metadata.pb new file mode 100755 index 0000000000000000000000000000000000000000..01e5f70bfa498b7a46d6c58a690bc945ddeb2b8f --- /dev/null +++ b/.model/lstm/keras_metadata.pb @@ -0,0 +1,10 @@ + +´(root"_tf_keras_sequential*({"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "LSTM", "config": {"name": "lstm", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 9, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "LSTM", "config": {"name": "lstm", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}, "shared_object_id": 5}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 11}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +Ÿroot.layer_with_weights-0"_tf_keras_rnn_layer*ä +{"name": "lstm", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "LSTM", "config": {"name": "lstm", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}, "shared_object_id": 5, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, null, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}, "shared_object_id": 15}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +Âroot.layer_with_weights-1"_tf_keras_layer*‹{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 16}}, "shared_object_id": 16}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 16]}}2 +çroot.layer_with_weights-0.cell"_tf_keras_layer*«{"name": "lstm_cell", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "LSTMCell", "config": {"name": "lstm_cell", "trainable": true, "dtype": "float32", "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}, "shared_object_id": 4}2 +¹>root.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 17}2 +Ÿ?root.keras_api.metrics.1"_tf_keras_metric*è{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}2 +è@root.keras_api.metrics.2"_tf_keras_metric*±{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}2 +ßAroot.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}2 \ No newline at end of file diff --git a/.model/lstm/saved_model.pb b/.model/lstm/saved_model.pb new file mode 100755 index 0000000000000000000000000000000000000000..89ec9e1fd65976f1177bdf98a2e0182073b03a8a Binary files /dev/null and b/.model/lstm/saved_model.pb differ diff --git a/.model/lstm/variables/variables.data-00000-of-00001 b/.model/lstm/variables/variables.data-00000-of-00001 new file mode 100755 index 0000000000000000000000000000000000000000..e251074298beb95730bbf2acaed354e54e769e78 Binary files /dev/null and b/.model/lstm/variables/variables.data-00000-of-00001 differ diff --git a/.model/lstm/variables/variables.index b/.model/lstm/variables/variables.index new file mode 100755 index 0000000000000000000000000000000000000000..a81c9896112a110c0ca3f6ef25a83759895e1cc5 Binary files /dev/null and b/.model/lstm/variables/variables.index differ diff --git a/.model/lstm_old/keras_metadata.pb b/.model/lstm_old/keras_metadata.pb new file mode 100755 index 0000000000000000000000000000000000000000..01e5f70bfa498b7a46d6c58a690bc945ddeb2b8f --- /dev/null +++ b/.model/lstm_old/keras_metadata.pb @@ -0,0 +1,10 @@ + +´(root"_tf_keras_sequential*({"name": "sequential", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "must_restore_from_config": false, "class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}}, {"class_name": "LSTM", "config": {"name": "lstm", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}}]}, "shared_object_id": 9, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}, "is_graph_network": true, "full_save_spec": {"class_name": "__tuple__", "items": [[{"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}], {}]}, "save_spec": {"class_name": "TypeSpec", "type_spec": "tf.TensorSpec", "serialized": [{"class_name": "TensorShape", "items": [null, 10, 7]}, "float32", "input_1"]}, "keras_version": "2.8.0", "backend": "tensorflow", "model_config": {"class_name": "Sequential", "config": {"name": "sequential", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": {"class_name": "__tuple__", "items": [null, 10, 7]}, "dtype": "float32", "sparse": false, "ragged": false, "name": "input_1"}, "shared_object_id": 0}, {"class_name": "LSTM", "config": {"name": "lstm", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}, "shared_object_id": 5}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8}]}}, "training_config": {"loss": {"class_name": "CategoricalCrossentropy", "config": {"reduction": "auto", "name": "categorical_crossentropy", "from_logits": true, "label_smoothing": 0.0, "axis": -1}, "shared_object_id": 11}, "metrics": [[{"class_name": "CategoricalCrossentropy", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}, {"class_name": "CategoricalAccuracy", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}, {"class_name": "CategoricalHinge", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}]], "weighted_metrics": null, "loss_weights": null, "optimizer_config": {"class_name": "Adam", "config": {"name": "Adam", "learning_rate": 0.0010000000474974513, "decay": 0.0, "beta_1": 0.8999999761581421, "beta_2": 0.9990000128746033, "epsilon": 1e-07, "amsgrad": false}}}}2 +Ÿroot.layer_with_weights-0"_tf_keras_rnn_layer*ä +{"name": "lstm", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "LSTM", "config": {"name": "lstm", "trainable": true, "dtype": "float32", "return_sequences": false, "return_state": false, "go_backwards": false, "stateful": false, "unroll": false, "time_major": false, "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}, "shared_object_id": 5, "input_spec": [{"class_name": "InputSpec", "config": {"dtype": null, "shape": {"class_name": "__tuple__", "items": [null, null, 7]}, "ndim": 3, "max_ndim": null, "min_ndim": null, "axes": {}}, "shared_object_id": 15}], "build_input_shape": {"class_name": "TensorShape", "items": [null, 10, 7]}}2 +Âroot.layer_with_weights-1"_tf_keras_layer*‹{"name": "dense", "trainable": true, "expects_training_arg": false, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 4, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 6}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 7}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "shared_object_id": 8, "input_spec": {"class_name": "InputSpec", "config": {"dtype": null, "shape": null, "ndim": null, "max_ndim": null, "min_ndim": 2, "axes": {"-1": 16}}, "shared_object_id": 16}, "build_input_shape": {"class_name": "TensorShape", "items": [null, 16]}}2 +çroot.layer_with_weights-0.cell"_tf_keras_layer*«{"name": "lstm_cell", "trainable": true, "expects_training_arg": true, "dtype": "float32", "batch_input_shape": null, "stateful": false, "must_restore_from_config": false, "class_name": "LSTMCell", "config": {"name": "lstm_cell", "trainable": true, "dtype": "float32", "units": 16, "activation": "tanh", "recurrent_activation": "sigmoid", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}, "shared_object_id": 1}, "recurrent_initializer": {"class_name": "Orthogonal", "config": {"gain": 1.0, "seed": null}, "shared_object_id": 2}, "bias_initializer": {"class_name": "Zeros", "config": {}, "shared_object_id": 3}, "unit_forget_bias": true, "kernel_regularizer": null, "recurrent_regularizer": null, "bias_regularizer": null, "kernel_constraint": null, "recurrent_constraint": null, "bias_constraint": null, "dropout": 0.0, "recurrent_dropout": 0.0, "implementation": 2}, "shared_object_id": 4}2 +¹>root.keras_api.metrics.0"_tf_keras_metric*‚{"class_name": "Mean", "name": "loss", "dtype": "float32", "config": {"name": "loss", "dtype": "float32"}, "shared_object_id": 17}2 +Ÿ?root.keras_api.metrics.1"_tf_keras_metric*è{"class_name": "CategoricalCrossentropy", "name": "categorical_crossentropy", "dtype": "float32", "config": {"name": "categorical_crossentropy", "dtype": "float32", "from_logits": true, "label_smoothing": 0}, "shared_object_id": 12}2 +è@root.keras_api.metrics.2"_tf_keras_metric*±{"class_name": "CategoricalAccuracy", "name": "categorical_accuracy", "dtype": "float32", "config": {"name": "categorical_accuracy", "dtype": "float32"}, "shared_object_id": 13}2 +ßAroot.keras_api.metrics.3"_tf_keras_metric*¨{"class_name": "CategoricalHinge", "name": "categorical_hinge", "dtype": "float32", "config": {"name": "categorical_hinge", "dtype": "float32"}, "shared_object_id": 14}2 \ No newline at end of file diff --git a/.model/lstm_old/saved_model.pb b/.model/lstm_old/saved_model.pb new file mode 100755 index 0000000000000000000000000000000000000000..4ebe7a8f70872e2e984bc6130d9990d5dff89769 Binary files /dev/null and b/.model/lstm_old/saved_model.pb differ diff --git a/.model/lstm_old/variables/variables.data-00000-of-00001 b/.model/lstm_old/variables/variables.data-00000-of-00001 new file mode 100755 index 0000000000000000000000000000000000000000..ca6572b0159eb41a9b2b7b74de019cc8e4b575ba Binary files /dev/null and b/.model/lstm_old/variables/variables.data-00000-of-00001 differ diff --git a/.model/lstm_old/variables/variables.index b/.model/lstm_old/variables/variables.index new file mode 100755 index 0000000000000000000000000000000000000000..d7e54b4c5f2b1a408dcecaf5c0a979dd043a5676 Binary files /dev/null and b/.model/lstm_old/variables/variables.index differ diff --git a/attention_model.py b/attention_model.py new file mode 100755 index 0000000000000000000000000000000000000000..f20fbfc0f7b9f2d7d3d00f8ca2606225cf33ee58 --- /dev/null +++ b/attention_model.py @@ -0,0 +1,21 @@ +from common import * +from attention import Attention + +# Hyper-parameters +ATTENTION_UNITS = 16 + +# Model Definition +def main(baseline=None): + am_model = keras.Sequential() + am_model.add(layers.Input(shape=(INPUT_TIME_STEP, INPUT_FEATURES_SIZE))) + am_model.add(Attention(ATTENTION_UNITS)) + am_model.add(layers.Dense(SLEEP_STAGES)) + am_model.build() + print(am_model.summary()) + am_history = compile_and_fit(model=am_model, window=wg, baseline=baseline) + print("Finished training") + am_model.save(".model/attention") + save_history(am_history.history, ".history/attention.csv") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/baseline_model.py b/baseline_model.py new file mode 100755 index 0000000000000000000000000000000000000000..1bbfb63c4e7f58d0e6acec92f79de7f156b387f7 --- /dev/null +++ b/baseline_model.py @@ -0,0 +1,25 @@ +from common import * + + +def main(): + global baseline_model + BASELINE_UNITS = 16 + baseline_model = keras.Sequential( + [ + layers.Input(shape=(INPUT_TIME_STEP, INPUT_FEATURES_SIZE)), + layers.Dense(BASELINE_UNITS), + # layers.Dense(BASELINE_UNITS), + # layers.Dense(BASELINE_UNITS), + layers.Flatten(), + layers.Dense(SLEEP_STAGES), + ] + ) + baseline_model.build() + print(baseline_model.summary()) + baseline_history = compile_and_fit(baseline_model, wg) + print("Finished training") + save_history(baseline_history.history, ".history/baseline.csv") + baseline_model.save(".model/baseline") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/common.py b/common.py new file mode 100644 index 0000000000000000000000000000000000000000..c3aca7b73666f4871341a13dbdae192449b34569 --- /dev/null +++ b/common.py @@ -0,0 +1,113 @@ +import tensorflow as tf +import numpy as np +from tensorflow import keras +from tensorflow.keras import layers +import pandas as pd + +TEST_SIZE = 365*3//5 +VALIDATION_SIZE = 365*4//5 + +BATCH_SIZE = 64 +INPUT_TIME_STEP = 10 # in minutes +INPUT_FEATURES_SIZE = 7 +SLEEP_STAGES = 4 +MAX_EPOCHS = 20 + +SLEEP_DATA_PATH = ".data/sleep_data_simple.csv" + +def training_test_split_by_unique_index(data, index: str, test_size: int = 10): + test_ids = np.random.choice(data[index].unique(), size = test_size, replace=False) + return data[~data[index].isin(test_ids)], data[data[index].isin(test_ids)] + + +# Adapted from https://www.tensorflow.org/tutorials/structured_data/time_series +class WindowGenerator(): + def __init__(self, data, index: str = "sleep_id", input_width: int = INPUT_TIME_STEP, validation_size: int = VALIDATION_SIZE, test_size: int = TEST_SIZE, input_feature_slice: slice = slice(1,100), label_feature_slice: slice = slice(-4,100), generate_data_now: bool = True): + # Partition data + self.training, self.testing = training_test_split_by_unique_index(data, index, test_size) + self.training, self.validation = training_test_split_by_unique_index(self.training, index, validation_size) + + # Window paramters + self.input_width = input_width + self.label_width = 1 + self.shift = 1 + + self.total_window_size = self.input_width + self.shift + + self.input_slice = slice(0, input_width) + self.input_indices = np.arange(self.total_window_size)[self.input_slice] + + self.label_start = self.total_window_size - self.label_width + self.labels_slice = slice(self.label_start, None) + self.label_indices = np.arange(self.total_window_size)[self.labels_slice] + + self.input_feature_slice = input_feature_slice + self.label_feature_slice = label_feature_slice + + self.sample_ds = self.make_dataset(data[data[index] == 0]) + + if generate_data_now: + self.training_ds = self.make_dataset(self.training, index) + self.validation_ds = self.make_dataset(self.validation, index) + self.testing_ds = self.make_dataset(self.testing, index) + + + def __repr__(self): + return "WindowGenerator:\n\t" +'\n\t'.join([ + f'Total window size: {self.total_window_size}', + f'Input indices: {self.input_indices}', + f'Label indices: {self.label_indices}', + ]) + + def split_window(self, features): + inputs = features[:, self.input_slice, self.input_feature_slice] + labels = tf.squeeze(features[:, self.labels_slice, self.label_feature_slice]) + inputs.set_shape([None, self.input_width, None]) + # labels.set_shape([None, self.label_width, None]) + return inputs, labels + + def make_dataset(self, data, index_group: str = "sleep_id", sort_by: str = "minutes_since_begin"): + ds_all = None + for i_group in data[index_group].unique(): + subset_data = np.array(data[data[index_group] == i_group].sort_values(by=[sort_by]), dtype=np.float32) + ds = tf.keras.utils.timeseries_dataset_from_array( + data=subset_data, + targets=None, + sequence_length=self.total_window_size, + sequence_stride=1, + shuffle=False, + batch_size=BATCH_SIZE,) + ds_all = ds if ds_all is None else ds_all.concatenate(ds) + ds_all = ds_all.map(self.split_window) + + return ds_all + +# Adapted from https://www.tensorflow.org/tutorials/structured_data/time_series#linear_model +def compile_and_fit(model, window: WindowGenerator, loss = tf.losses.CategoricalCrossentropy(from_logits=True), optimizer = tf.optimizers.Adam(), metrics = None, early_stop: bool = True, patience:int = 5, baseline = None, epochs: int = MAX_EPOCHS): + if metrics is None: + metrics = [tf.keras.metrics.CategoricalCrossentropy(from_logits=True), tf.keras.metrics.CategoricalAccuracy(), tf.keras.metrics.CategoricalHinge()] + + callbacks = [] + if early_stop: + early_stopping = tf.keras.callbacks.EarlyStopping( + monitor='val_loss', + patience=patience, + baseline = baseline, + mode='min' + ) + callbacks.append(early_stopping) + + model.compile( + loss=loss, + optimizer=optimizer, + metrics=metrics, + ) + + return model.fit(window.training_ds, epochs=epochs, validation_data=window.validation_ds, callbacks=callbacks) + +def save_history(history, file_name: str = "history.csv"): + pd.DataFrame.from_dict(history).to_csv(file_name, index=False) + + +sleep_data = pd.read_csv(SLEEP_DATA_PATH) +wg = WindowGenerator(sleep_data) diff --git a/gru_model.py b/gru_model.py new file mode 100755 index 0000000000000000000000000000000000000000..50b53829d1c7f6f5b17d7f44afa1c60aac1e4f7d --- /dev/null +++ b/gru_model.py @@ -0,0 +1,20 @@ +from common import * + +# Hyper-parameters +GRU_UNITS = 16 + +# Model Definition +def main(baseline=None): + gru_model = keras.Sequential() + gru_model.add(layers.Input(shape=(INPUT_TIME_STEP, INPUT_FEATURES_SIZE))) + gru_model.add(layers.GRU(GRU_UNITS)) + gru_model.add(layers.Dense(SLEEP_STAGES)) + gru_model.build() + print(gru_model.summary()) + gru_history = compile_and_fit(model=gru_model, window=wg, baseline=baseline) + print("Finished training") + gru_model.save(".model/gru") + save_history(gru_history.history, ".history/gru.csv") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/lstm_model.py b/lstm_model.py new file mode 100755 index 0000000000000000000000000000000000000000..40eb96515fdb57eb1ccd15601bb31547c5996fe9 --- /dev/null +++ b/lstm_model.py @@ -0,0 +1,22 @@ +from common import * + +# Hyper-parameters +LSTM_UNITS = 16 + +# Model Definition +def main(baseline=None): + lstm_model = keras.Sequential() + lstm_model.add(layers.Input(shape=(INPUT_TIME_STEP, INPUT_FEATURES_SIZE))) + # lstm_model.add(layers.LSTM(LSTM_UNITS, stateful=False, return_sequences=True)) + # lstm_model.add(layers.LSTM(LSTM_UNITS, stateful=False, return_sequences=True)) + lstm_model.add(layers.LSTM(LSTM_UNITS, stateful=False, return_sequences=False)) + lstm_model.add(layers.Dense(SLEEP_STAGES)) + lstm_model.build() + print(lstm_model.summary()) + lstm_history = compile_and_fit(model=lstm_model, window=wg, baseline=baseline) + print("Finished training") + lstm_model.save(".model/lstm") + save_history(lstm_history.history, ".history/lstm.csv") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/simple_alarm_clock.py b/simple_alarm_clock.py index 306dde8135b5a7369248ce6433d5bac85432e040..e9c981ec0875ba8fe45c1d0f5c14cca54e0b4e5d 100644 --- a/simple_alarm_clock.py +++ b/simple_alarm_clock.py @@ -3,7 +3,8 @@ from enum import Enum, auto from datetime import time, datetime from typing import Optional, Any from time import sleep -import vlc +from pynput import keyboard +from pynput.keyboard import Key, Controller # Simple Alarm Clock has 5 functionalities: # 1. Set Alarm Time - Set the time for the alarm to sound, does NOT make the alarm active @@ -12,20 +13,23 @@ import vlc # 4. Snooze Alarm - Stop the alarm sound and wait for some time to play the alarm again # 5. Stop Alarm - If the alarm is active or is playing, stop the alarm (deactivate state) -DEFAULT_VOLUME = 50 +ALARM_TIME = time(19, 13, 0) +SNOOZE_SEC = 5 +SNOOZE_KEY = keyboard.Key.up +ALARM_OFF_KEY = keyboard.Key.esc class AlarmState(Enum): SET = auto(), - STARTED = auto(), + RUNNING = auto(), PLAYING = auto(), SNOOZED = auto(), DEACTIVATED = auto(), @dataclass -class AlarmClock: - player: Optional +class BaseAlarmClock: + # player: Optional wake_time: time current_state: AlarmState = AlarmState.DEACTIVATED @@ -35,50 +39,68 @@ class AlarmClock: self.wake_time = wake_time return self.wake_time - def start_alarm(self, check_frequency: int = 1) -> bool: - print(f"STARTING ALARM") - self.current_state = AlarmState.STARTED - now = datetime.now().time() - if now >= self.wake_time: - return False - sleep_time_amount = check_frequency if check_frequency > 1 else 1 - while now < self.wake_time: - # Sleep for some time - sleep(sleep_time_amount) - now = datetime.now().time() - self.sound_alarm() - return True - - def sound_alarm(self, sound: Optional = None, volume: int = DEFAULT_VOLUME): - print(f"SOUNDING ALARM") + def start_alarm(self, check_frequency: int = 1): + print("STARTING ALARM") + self.current_state = AlarmState.RUNNING + # now = datetime.now().time() + # if now >= self.wake_time: + # return False + # sleep_time_amount = max(check_frequency, 1) + # while now < self.wake_time: + # # Sleep for some time + # sleep(sleep_time_amount) + # now = datetime.now().time() + # self.sound_alarm() + # return True + + def sound_alarm(self): + print("SOUNDING ALARM") self.current_state = AlarmState.PLAYING - if sound is not None: - self.player.set_media(sound) - self.player.audio_set_volume(volume) - self.player.play() + # if sound is not None: + # self.player.set_media(sound) + # self.player.audio_set_volume(volume) + # self.player.play() - def snooze_alarm(self, snooze_time: int = 60): - print(f"SNOOZING ALARM") + def snooze_alarm(self, snooze_time: int = SNOOZE_SEC): + print("SNOOZING ALARM") self.current_state = AlarmState.SNOOZED - self.player.pause() + # self.player.pause() # Maybe make this async later sleep(snooze_time) - self.player.play() + # self.player.play() if self.current_state is AlarmState.SNOOZED: self.sound_alarm() def stop_alarm(self, deactivate: bool = True): - print(f"STOPPING ALARM") + print("STOPPING ALARM") if self.current_state is AlarmState.PLAYING: - self.player.stop() + print("STOPPED PLAYING ALARM") + # self.player.stop() self.current_state = AlarmState.DEACTIVATED if deactivate else AlarmState.SET + def alarm_check_reached(self, current_time = datetime.now().time()) -> bool: + result = current_time >= self.wake_time if self.current_state is AlarmState.RUNNING else False + print(f"{result = }") + return result + + +def simple_alarm_mode(alarm_time): + alarm_clock = BaseAlarmClock(alarm_time) + alarm_clock.start_alarm() + while not alarm_clock.alarm_check_reached(): + print(f"ALARM SLEEPING @: {datetime.now().time()}") + sleep(1) + alarm_clock.sound_alarm() + while alarm_clock.current_state is not AlarmState.DEACTIVATED: + with keyboard.Events() as events: + for event in events: + if event.key == ALARM_OFF_KEY: + alarm_clock.stop_alarm() + break + elif event.key == SNOOZE_KEY: + alarm_clock.snooze_alarm() + break -def simple_alarm_mode(): - alarm_clock = AlarmClock(math, ALARM_TIME) - - -ALARM_TIME = time(7, 0, 0) if __name__ == '__main__': - simple_alarm_mode() \ No newline at end of file + simple_alarm_mode(ALARM_TIME) diff --git a/smart_alarm_clock.py b/smart_alarm_clock.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tf_model.ipynb b/tf_model.ipynb index 0043c5fe5ef149c85387a31c0d3dd8301289c3b6..1256f64518b0b070fd4b622c378bd36a9844a4d8 100644 --- a/tf_model.ipynb +++ b/tf_model.ipynb @@ -25,7 +25,8 @@ "from tensorflow import keras\n", "from tensorflow.keras import layers\n", "import pandas as pd\n", - "from attention import Attention" + "from attention import Attention\n", + "import json" ] }, { @@ -53,7 +54,8 @@ "source": [ "# CONSTANTS\n", "RAW_SLEEP_DATA_PATH = \".data/raw_bed_sleep-state.csv\"\n", - "CLEANED_SLEEP_DATA_PATH = \".data/clean_bed_sleep-state.csv\"" + "CLEANED_SLEEP_DATA_PATH = \".data/clean_bed_sleep-state.csv\"\n", + "SLEEP_DATA_PATH = \".data/sleep_data_simple.csv\"" ] }, { @@ -692,14 +694,14 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ - "TEST_SIZE = 122\n", - "VALIDATION_SIZE = 183\n", + "TEST_SIZE = 365*3//5\n", + "VALIDATION_SIZE = 365*4//5\n", "\n", - "BATCH_SIZE = 32\n", + "BATCH_SIZE = 64\n", "INPUT_TIME_STEP = 10 # in minutes\n", "INPUT_FEATURES_SIZE = 7\n", "MAX_EPOCHS = 20" @@ -707,16 +709,16 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 16, "metadata": {}, "outputs": [], "source": [ - "sleep_data = pd.read_csv(\".data/sleep_data_simple.csv\")" + "sleep_data = pd.read_csv(SLEEP_DATA_PATH)" ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -740,7 +742,6 @@ " <thead>\n", " <tr style=\"text-align: right;\">\n", " <th></th>\n", - " <th>Unnamed: 0</th>\n", " <th>sleep_id</th>\n", " <th>minutes_since_begin</th>\n", " <th>stage_start_hour</th>\n", @@ -756,7 +757,6 @@ " <th>0</th>\n", " <td>0</td>\n", " <td>0</td>\n", - " <td>0</td>\n", " <td>8</td>\n", " <td>18</td>\n", " <td>1.0</td>\n", @@ -766,7 +766,6 @@ " </tr>\n", " <tr>\n", " <th>1</th>\n", - " <td>1</td>\n", " <td>0</td>\n", " <td>1</td>\n", " <td>8</td>\n", @@ -778,7 +777,6 @@ " </tr>\n", " <tr>\n", " <th>2</th>\n", - " <td>2</td>\n", " <td>0</td>\n", " <td>2</td>\n", " <td>8</td>\n", @@ -790,7 +788,6 @@ " </tr>\n", " <tr>\n", " <th>3</th>\n", - " <td>3</td>\n", " <td>0</td>\n", " <td>3</td>\n", " <td>8</td>\n", @@ -802,7 +799,6 @@ " </tr>\n", " <tr>\n", " <th>4</th>\n", - " <td>4</td>\n", " <td>0</td>\n", " <td>4</td>\n", " <td>8</td>\n", @@ -822,11 +818,9 @@ " <td>...</td>\n", " <td>...</td>\n", " <td>...</td>\n", - " <td>...</td>\n", " </tr>\n", " <tr>\n", " <th>551037</th>\n", - " <td>551037</td>\n", " <td>1132</td>\n", " <td>426</td>\n", " <td>13</td>\n", @@ -838,7 +832,6 @@ " </tr>\n", " <tr>\n", " <th>551038</th>\n", - " <td>551038</td>\n", " <td>1132</td>\n", " <td>427</td>\n", " <td>13</td>\n", @@ -850,7 +843,6 @@ " </tr>\n", " <tr>\n", " <th>551039</th>\n", - " <td>551039</td>\n", " <td>1132</td>\n", " <td>428</td>\n", " <td>13</td>\n", @@ -862,7 +854,6 @@ " </tr>\n", " <tr>\n", " <th>551040</th>\n", - " <td>551040</td>\n", " <td>1132</td>\n", " <td>429</td>\n", " <td>13</td>\n", @@ -874,7 +865,6 @@ " </tr>\n", " <tr>\n", " <th>551041</th>\n", - " <td>551041</td>\n", " <td>1132</td>\n", " <td>430</td>\n", " <td>13</td>\n", @@ -886,53 +876,53 @@ " </tr>\n", " </tbody>\n", "</table>\n", - "<p>551042 rows × 9 columns</p>\n", + "<p>551042 rows × 8 columns</p>\n", "</div>" ], "text/plain": [ - " Unnamed: 0 sleep_id minutes_since_begin stage_start_hour \\\n", - "0 0 0 0 8 \n", - "1 1 0 1 8 \n", - "2 2 0 2 8 \n", - "3 3 0 3 8 \n", - "4 4 0 4 8 \n", - "... ... ... ... ... \n", - "551037 551037 1132 426 13 \n", - "551038 551038 1132 427 13 \n", - "551039 551039 1132 428 13 \n", - "551040 551040 1132 429 13 \n", - "551041 551041 1132 430 13 \n", + " sleep_id minutes_since_begin stage_start_hour stage_start_minute \\\n", + "0 0 0 8 18 \n", + "1 0 1 8 19 \n", + "2 0 2 8 20 \n", + "3 0 3 8 21 \n", + "4 0 4 8 22 \n", + "... ... ... ... ... \n", + "551037 1132 426 13 17 \n", + "551038 1132 427 13 18 \n", + "551039 1132 428 13 19 \n", + "551040 1132 429 13 20 \n", + "551041 1132 430 13 21 \n", "\n", - " stage_start_minute awake_probability rem_probability \\\n", - "0 18 1.0 0.0 \n", - "1 19 1.0 0.0 \n", - "2 20 1.0 0.0 \n", - "3 21 1.0 0.0 \n", - "4 22 1.0 0.0 \n", - "... ... ... ... \n", - "551037 17 0.0 0.0 \n", - "551038 18 0.0 0.0 \n", - "551039 19 0.0 0.0 \n", - "551040 20 0.0 0.0 \n", - "551041 21 0.0 0.0 \n", + " awake_probability rem_probability light_probability \\\n", + "0 1.0 0.0 0.0 \n", + "1 1.0 0.0 0.0 \n", + "2 1.0 0.0 0.0 \n", + "3 1.0 0.0 0.0 \n", + "4 1.0 0.0 0.0 \n", + "... ... ... ... \n", + "551037 0.0 0.0 1.0 \n", + "551038 0.0 0.0 1.0 \n", + "551039 0.0 0.0 1.0 \n", + "551040 0.0 0.0 1.0 \n", + "551041 0.0 0.0 1.0 \n", "\n", - " light_probability deep_probability \n", - "0 0.0 0.0 \n", - "1 0.0 0.0 \n", - "2 0.0 0.0 \n", - "3 0.0 0.0 \n", - "4 0.0 0.0 \n", - "... ... ... \n", - "551037 1.0 0.0 \n", - "551038 1.0 0.0 \n", - "551039 1.0 0.0 \n", - "551040 1.0 0.0 \n", - "551041 1.0 0.0 \n", + " deep_probability \n", + "0 0.0 \n", + "1 0.0 \n", + "2 0.0 \n", + "3 0.0 \n", + "4 0.0 \n", + "... ... \n", + "551037 0.0 \n", + "551038 0.0 \n", + "551039 0.0 \n", + "551040 0.0 \n", + "551041 0.0 \n", "\n", - "[551042 rows x 9 columns]" + "[551042 rows x 8 columns]" ] }, - "execution_count": 35, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -950,7 +940,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -961,7 +951,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -969,7 +959,7 @@ "class WindowGenerator():\n", " def __init__(self, data, index: str = \"sleep_id\", input_width: int = INPUT_TIME_STEP, validation_size: int = VALIDATION_SIZE, test_size: int = TEST_SIZE, input_feature_slice: slice = slice(1,100), label_feature_slice: slice = slice(-4,100), generate_data_now: bool = True):\n", " # Partition data\n", - " self.training, self.testing = training_test_split_by_unique_index(sleep_data, index, test_size)\n", + " self.training, self.testing = training_test_split_by_unique_index(data, index, test_size)\n", " self.training, self.validation = training_test_split_by_unique_index(self.training, index, validation_size)\n", "\n", " # Window paramters\n", @@ -989,7 +979,7 @@ " self.input_feature_slice = input_feature_slice\n", " self.label_feature_slice = label_feature_slice\n", "\n", - " self.sample_ds = self.make_dataset(sleep_data[sleep_data[index] == 0])\n", + " self.sample_ds = self.make_dataset(data[data[index] == 0])\n", "\n", " if generate_data_now:\n", " self.training_ds = self.make_dataset(self.training, index)\n", @@ -1025,139 +1015,286 @@ " ds_all = ds if ds_all is None else ds_all.concatenate(ds)\n", " ds_all = ds_all.map(self.split_window)\n", "\n", - " return ds_all\n", - "\n", - " # def generate_all_datasets(self):\n", - " # self._training_ds = self.make_dataset(self.training)\n", - " # self._validation_ds = self.make_dataset(self.validation)\n", - " # self._testing_ds = self.make_dataset(self.testing)\n", + " return ds_all" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### General Model Helper" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "# Adapted from https://www.tensorflow.org/tutorials/structured_data/time_series#linear_model\n", + "def compile_and_fit(model, window: WindowGenerator, loss = tf.losses.CategoricalCrossentropy(from_logits=True), optimizer = tf.optimizers.Adam(), metrics = None, early_stop: bool = True, patience:int = 5, baseline = None, epochs: int = MAX_EPOCHS):\n", + " if metrics is None:\n", + " metrics = [tf.keras.metrics.CategoricalCrossentropy(from_logits=True), tf.keras.metrics.CategoricalAccuracy(), tf.keras.metrics.CategoricalHinge()]\n", "\n", - " # def training_dataset(self):\n", - " # if self._training_ds is None:\n", - " # self._training_ds = self.make_dataset(self.training)\n", - " # return self._training_ds\n", + " callbacks = []\n", + " if early_stop:\n", + " early_stopping = tf.keras.callbacks.EarlyStopping(\n", + " monitor='val_loss',\n", + " patience=patience,\n", + " baseline = baseline,\n", + " mode='min'\n", + " )\n", + " callbacks.append(early_stopping)\n", "\n", - " # def validation_dataset(self):\n", - " # if self._validation_ds is None:\n", - " # self._validation_ds = self.make_dataset(self.validation)\n", - " # return self._validation_ds\n", + " model.compile(\n", + " loss=loss,\n", + " optimizer=optimizer,\n", + " metrics=metrics,\n", + " )\n", "\n", - " # def test_dataset(self):\n", - " # if self._testing_ds is None:\n", - " # self._testing_ds = self.make_dataset(self.testing)\n", - " # return self._testing_ds" + " return model.fit(window.training_ds, epochs=epochs, validation_data=window.validation_ds, callbacks=callbacks)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### Data Prep\n", - "\n", - "All inputs follow: (batch_size, timesteps, input_dim)" + "### Experimenting" ] }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 23, "metadata": {}, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'sleep_id'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/Documents/School Folder/CS 437/Lab/Final Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py:3621\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3619'>3620</a>\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3620'>3621</a>\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_engine\u001b[39m.\u001b[39;49mget_loc(casted_key)\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3621'>3622</a>\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyError\u001b[39;00m \u001b[39mas\u001b[39;00m err:\n", - "File \u001b[0;32mpandas/_libs/index.pyx:136\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32mpandas/_libs/index.pyx:163\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5198\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5206\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 'sleep_id'", - "\nThe above exception was the direct cause of the following exception:\n", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m/Users/nowadmin/Documents/School Folder/CS 437/Lab/Final Project/tf_model.ipynb Cell 33'\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000072?line=0'>1</a>\u001b[0m wg \u001b[39m=\u001b[39m WindowGenerator(sleep_data)\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000072?line=1'>2</a>\u001b[0m wg\n", - "\u001b[1;32m/Users/nowadmin/Documents/School Folder/CS 437/Lab/Final Project/tf_model.ipynb Cell 31'\u001b[0m in \u001b[0;36mWindowGenerator.__init__\u001b[0;34m(self, data, index, input_width, validation_size, test_size, input_feature_slice, label_feature_slice, generate_data_now)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000065?line=2'>3</a>\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__init__\u001b[39m(\u001b[39mself\u001b[39m, data, index: \u001b[39mstr\u001b[39m \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39msleep_id\u001b[39m\u001b[39m\"\u001b[39m, input_width: \u001b[39mint\u001b[39m \u001b[39m=\u001b[39m INPUT_TIME_STEP, validation_size: \u001b[39mint\u001b[39m \u001b[39m=\u001b[39m VALIDATION_SIZE, test_size: \u001b[39mint\u001b[39m \u001b[39m=\u001b[39m TEST_SIZE, input_feature_slice: \u001b[39mslice\u001b[39m \u001b[39m=\u001b[39m \u001b[39mslice\u001b[39m(\u001b[39m1\u001b[39m,\u001b[39m100\u001b[39m), label_feature_slice: \u001b[39mslice\u001b[39m \u001b[39m=\u001b[39m \u001b[39mslice\u001b[39m(\u001b[39m-\u001b[39m\u001b[39m4\u001b[39m,\u001b[39m100\u001b[39m), generate_data_now: \u001b[39mbool\u001b[39m \u001b[39m=\u001b[39m \u001b[39mTrue\u001b[39;00m):\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000065?line=3'>4</a>\u001b[0m \u001b[39m# Partition data\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000065?line=4'>5</a>\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtraining, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtesting \u001b[39m=\u001b[39m training_test_split_by_unique_index(sleep_data, index, test_size)\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000065?line=5'>6</a>\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtraining, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mvalidation \u001b[39m=\u001b[39m training_test_split_by_unique_index(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtraining, index, validation_size)\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000065?line=7'>8</a>\u001b[0m \u001b[39m# Window paramters\u001b[39;00m\n", - "\u001b[1;32m/Users/nowadmin/Documents/School Folder/CS 437/Lab/Final Project/tf_model.ipynb Cell 30'\u001b[0m in \u001b[0;36mtraining_test_split_by_unique_index\u001b[0;34m(data, index, test_size)\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000066?line=0'>1</a>\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mtraining_test_split_by_unique_index\u001b[39m(data, index: \u001b[39mstr\u001b[39m, test_size: \u001b[39mint\u001b[39m \u001b[39m=\u001b[39m \u001b[39m10\u001b[39m):\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000066?line=1'>2</a>\u001b[0m test_ids \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39mrandom\u001b[39m.\u001b[39mchoice(data[index]\u001b[39m.\u001b[39munique(), size \u001b[39m=\u001b[39m test_size, replace\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m)\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/tf_model.ipynb#ch0000066?line=2'>3</a>\u001b[0m \u001b[39mreturn\u001b[39;00m data[\u001b[39m~\u001b[39mdata[index]\u001b[39m.\u001b[39misin(test_ids)], data[data[index]\u001b[39m.\u001b[39misin(test_ids)]\n", - "File \u001b[0;32m~/Documents/School Folder/CS 437/Lab/Final Project/venv/lib/python3.10/site-packages/pandas/core/frame.py:3505\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/frame.py?line=3502'>3503</a>\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mcolumns\u001b[39m.\u001b[39mnlevels \u001b[39m>\u001b[39m \u001b[39m1\u001b[39m:\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/frame.py?line=3503'>3504</a>\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_getitem_multilevel(key)\n\u001b[0;32m-> <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/frame.py?line=3504'>3505</a>\u001b[0m indexer \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcolumns\u001b[39m.\u001b[39;49mget_loc(key)\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/frame.py?line=3505'>3506</a>\u001b[0m \u001b[39mif\u001b[39;00m is_integer(indexer):\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/frame.py?line=3506'>3507</a>\u001b[0m indexer \u001b[39m=\u001b[39m [indexer]\n", - "File \u001b[0;32m~/Documents/School Folder/CS 437/Lab/Final Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py:3623\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3620'>3621</a>\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_engine\u001b[39m.\u001b[39mget_loc(casted_key)\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3621'>3622</a>\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mKeyError\u001b[39;00m \u001b[39mas\u001b[39;00m err:\n\u001b[0;32m-> <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3622'>3623</a>\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mKeyError\u001b[39;00m(key) \u001b[39mfrom\u001b[39;00m \u001b[39merr\u001b[39;00m\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3623'>3624</a>\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mTypeError\u001b[39;00m:\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3624'>3625</a>\u001b[0m \u001b[39m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3625'>3626</a>\u001b[0m \u001b[39m# InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3626'>3627</a>\u001b[0m \u001b[39m# the TypeError.\u001b[39;00m\n\u001b[1;32m <a href='file:///Users/nowadmin/Documents/School%20Folder/CS%20437/Lab/Final%20Project/venv/lib/python3.10/site-packages/pandas/core/indexes/base.py?line=3627'>3628</a>\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_check_indexing_error(key)\n", - "\u001b[0;31mKeyError\u001b[0m: 'sleep_id'" - ] - } - ], + "outputs": [], "source": [ - "wg = WindowGenerator(sleep_data)\n", - "wg" + "# USE SUBSET OF DATA FOR EXPERIMENTING\n", + "sleep_data_sub = sleep_data[sleep_data.sleep_id < 2000]" ] }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 24, "metadata": {}, "outputs": [], "source": [ - "sample = wg.sample_ds.take(1)" + "wg_sub = WindowGenerator(sleep_data_sub,validation_size=365, test_size=182)" ] }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Model: \"sequential_2\"\n", + "_________________________________________________________________\n", + " Layer (type) Output Shape Param # \n", + "=================================================================\n", + " dense_4 (Dense) (None, 10, 16) 128 \n", + " \n", + " flatten_2 (Flatten) (None, 160) 0 \n", + " \n", + " dense_5 (Dense) (None, 4) 644 \n", + " \n", + "=================================================================\n", + "Total params: 772\n", + "Trainable params: 772\n", + "Non-trainable params: 0\n", + "_________________________________________________________________\n", + "None\n" + ] + } + ], + "source": [ + "BASELINE_UNITS = 16\n", + "baseline_model = keras.Sequential(\n", + " [\n", + " layers.Input(shape=(INPUT_TIME_STEP, INPUT_FEATURES_SIZE)),\n", + " layers.Dense(BASELINE_UNITS),\n", + " # layers.Dense(BASELINE_UNITS),\n", + " # layers.Dense(BASELINE_UNITS),\n", + " layers.Flatten(),\n", + " layers.Dense(SLEEP_STAGES),\n", + " ]\n", + ")\n", + "baseline_model.build()\n", + "print(baseline_model.summary())" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Epoch 1/20\n", + "8955/8955 [==============================] - 60s 7ms/step - loss: 2.7762 - categorical_crossentropy: 2.7745 - categorical_accuracy: 0.7612 - categorical_hinge: 15.1798 - val_loss: 0.2711 - val_categorical_crossentropy: 0.2710 - val_categorical_accuracy: 0.9546 - val_categorical_hinge: 5.1404\n", + "Epoch 2/20\n", + "8955/8955 [==============================] - 60s 7ms/step - loss: 0.3110 - categorical_crossentropy: 0.3111 - categorical_accuracy: 0.9418 - categorical_hinge: 1.5468 - val_loss: 0.2106 - val_categorical_crossentropy: 0.2105 - val_categorical_accuracy: 0.9583 - val_categorical_hinge: 0.3215\n", + "Epoch 3/20\n", + "8955/8955 [==============================] - 60s 7ms/step - loss: 0.2253 - categorical_crossentropy: 0.2254 - categorical_accuracy: 0.9551 - categorical_hinge: 0.2726 - val_loss: 0.2068 - val_categorical_crossentropy: 0.2067 - val_categorical_accuracy: 0.9582 - val_categorical_hinge: 0.3656\n", + "Epoch 4/20\n", + "8955/8955 [==============================] - 63s 7ms/step - loss: 0.2059 - categorical_crossentropy: 0.2059 - categorical_accuracy: 0.9582 - categorical_hinge: 0.2735 - val_loss: 0.1957 - val_categorical_crossentropy: 0.1957 - val_categorical_accuracy: 0.9591 - val_categorical_hinge: 0.3622\n", + "Epoch 5/20\n", + "8955/8955 [==============================] - 82s 9ms/step - loss: 0.2016 - categorical_crossentropy: 0.2016 - categorical_accuracy: 0.9587 - categorical_hinge: 0.2638 - val_loss: 0.1970 - val_categorical_crossentropy: 0.1970 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.2868\n", + "Epoch 6/20\n", + "8955/8955 [==============================] - 72s 8ms/step - loss: 0.1995 - categorical_crossentropy: 0.1995 - categorical_accuracy: 0.9585 - categorical_hinge: 0.2506 - val_loss: 0.1973 - val_categorical_crossentropy: 0.1973 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.3453\n", + "Epoch 7/20\n", + "8955/8955 [==============================] - 75s 8ms/step - loss: 0.1991 - categorical_crossentropy: 0.1992 - categorical_accuracy: 0.9591 - categorical_hinge: 0.2518 - val_loss: 0.1969 - val_categorical_crossentropy: 0.1968 - val_categorical_accuracy: 0.9591 - val_categorical_hinge: 0.2474\n", + "Epoch 8/20\n", + "8955/8955 [==============================] - 75s 8ms/step - loss: 0.1983 - categorical_crossentropy: 0.1983 - categorical_accuracy: 0.9587 - categorical_hinge: 0.2560 - val_loss: 0.1957 - val_categorical_crossentropy: 0.1956 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.2912\n", + "Epoch 9/20\n", + "8955/8955 [==============================] - 76s 8ms/step - loss: 0.1965 - categorical_crossentropy: 0.1965 - categorical_accuracy: 0.9595 - categorical_hinge: 0.2328 - val_loss: 0.1957 - val_categorical_crossentropy: 0.1957 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.3268\n", + "Epoch 10/20\n", + "8955/8955 [==============================] - 77s 9ms/step - loss: 0.1961 - categorical_crossentropy: 0.1961 - categorical_accuracy: 0.9598 - categorical_hinge: 0.2375 - val_loss: 0.1954 - val_categorical_crossentropy: 0.1954 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.2518\n", + "Epoch 11/20\n", + "8955/8955 [==============================] - 72s 8ms/step - loss: 0.1980 - categorical_crossentropy: 0.1981 - categorical_accuracy: 0.9584 - categorical_hinge: 0.2387 - val_loss: 0.1948 - val_categorical_crossentropy: 0.1948 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.2795\n", + "Epoch 12/20\n", + "8955/8955 [==============================] - 69s 8ms/step - loss: 0.1959 - categorical_crossentropy: 0.1959 - categorical_accuracy: 0.9594 - categorical_hinge: 0.2465 - val_loss: 0.1950 - val_categorical_crossentropy: 0.1950 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.2824\n", + "Epoch 13/20\n", + "8955/8955 [==============================] - 65s 7ms/step - loss: 0.1960 - categorical_crossentropy: 0.1960 - categorical_accuracy: 0.9596 - categorical_hinge: 0.2413 - val_loss: 0.1955 - val_categorical_crossentropy: 0.1954 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.3859\n", + "Epoch 14/20\n", + "8955/8955 [==============================] - 68s 8ms/step - loss: 0.1959 - categorical_crossentropy: 0.1959 - categorical_accuracy: 0.9591 - categorical_hinge: 0.2280 - val_loss: 0.1941 - val_categorical_crossentropy: 0.1941 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.3046\n", + "Epoch 15/20\n", + "8955/8955 [==============================] - 77s 9ms/step - loss: 0.2031 - categorical_crossentropy: 0.2031 - categorical_accuracy: 0.9580 - categorical_hinge: 0.2336 - val_loss: 0.1949 - val_categorical_crossentropy: 0.1948 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.1873\n", + "Epoch 16/20\n", + "8955/8955 [==============================] - 68s 8ms/step - loss: 0.1966 - categorical_crossentropy: 0.1966 - categorical_accuracy: 0.9589 - categorical_hinge: 0.2361 - val_loss: 0.1938 - val_categorical_crossentropy: 0.1938 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.2056\n", + "Epoch 17/20\n", + "8955/8955 [==============================] - 67s 7ms/step - loss: 0.1924 - categorical_crossentropy: 0.1924 - categorical_accuracy: 0.9599 - categorical_hinge: 0.2510 - val_loss: 0.1934 - val_categorical_crossentropy: 0.1934 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.3111\n", + "Epoch 18/20\n", + "8955/8955 [==============================] - 67s 7ms/step - loss: 0.2079 - categorical_crossentropy: 0.2079 - categorical_accuracy: 0.9569 - categorical_hinge: 0.3273 - val_loss: 0.1930 - val_categorical_crossentropy: 0.1929 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.2956\n", + "Epoch 19/20\n", + "8955/8955 [==============================] - 67s 7ms/step - loss: 0.1923 - categorical_crossentropy: 0.1923 - categorical_accuracy: 0.9599 - categorical_hinge: 0.3248 - val_loss: 0.1924 - val_categorical_crossentropy: 0.1924 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.6417\n", + "Epoch 20/20\n", + "8955/8955 [==============================] - 68s 8ms/step - loss: 0.1950 - categorical_crossentropy: 0.1950 - categorical_accuracy: 0.9595 - categorical_hinge: 0.3199 - val_loss: 0.1935 - val_categorical_crossentropy: 0.1935 - val_categorical_accuracy: 0.9592 - val_categorical_hinge: 0.5098\n" + ] + } + ], "source": [ - "sample_array = list(sample.as_numpy_iterator())" + "baseline_history = compile_and_fit(baseline_model, wg_sub)" ] }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "((10, 7), (4,))" + "dict_keys(['loss', 'categorical_crossentropy', 'categorical_accuracy', 'categorical_hinge', 'val_loss', 'val_categorical_crossentropy', 'val_categorical_accuracy', 'val_categorical_hinge'])" ] }, - "execution_count": 63, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "INDEX_TIMESTEP = 18\n", - "sample_array[0][0][INDEX_TIMESTEP], sample_array[0][1][INDEX_TIMESTEP]" + "baseline_history.history.keys()" ] }, { - "cell_type": "markdown", + "cell_type": "code", + "execution_count": 32, "metadata": {}, + "outputs": [], "source": [ - "### General Model Helper" + "save_history(baseline_history.history, \".history/baseline.csv\")" ] }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ - "# Adapted from https://www.tensorflow.org/tutorials/structured_data/time_series#linear_model\n", - "def compile_and_fit(model, window: WindowGenerator, loss = tf.losses.MeanSquaredError(), optimizer = tf.optimizers.Adam(), metrics = tf.metrics.MeanAbsoluteError(), patience:int = 2, epochs: int = MAX_EPOCHS):\n", - " early_stopping = tf.keras.callbacks.EarlyStopping(\n", - " monitor='val_loss',\n", - " patience=patience,\n", - " mode='min'\n", - " )\n", - "\n", - " model.compile(\n", - " loss=loss,\n", - " optimizer=optimizer,\n", - " metrics=metrics,\n", - " )\n", + "def save_history(history, file_name: str = \"history.csv\"):\n", + " pd.DataFrame.from_dict(history).to_csv(file_name, index=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2022-05-11 15:02:03.185843: W tensorflow/python/util/util.cc:368] Sets are not currently considered sequences, but this may change in the future, so consider avoiding using them.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO:tensorflow:Assets written to: .model/baseline/assets\n" + ] + } + ], + "source": [ + "baseline_model.save(\".model/baseline\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Data Prep\n", "\n", - " return model.fit(window.training_ds, epochs=epochs, validation_data=window.validation_ds, callbacks=[early_stopping])" + "All inputs follow: (batch_size, timesteps, input_dim)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "WindowGenerator:\n", + "\tTotal window size: 11\n", + "\tInput indices: [0 1 2 3 4 5 6 7 8 9]\n", + "\tLabel indices: [10]" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wg = WindowGenerator(sleep_data)\n", + "wg" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "9647" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(wg.training_ds)" ] }, { @@ -1169,41 +1306,20 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "# Hyper-parameters\n", - "LSTM_UNITS = 16\n", + "LSTM_UNITS = 8\n", "LSTM_LEARNING_RATE = 0.0001" ] }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 37, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Model: \"sequential_7\"\n", - "_________________________________________________________________\n", - " Layer (type) Output Shape Param # \n", - "=================================================================\n", - " lstm_8 (LSTM) (None, 16) 1536 \n", - " \n", - " dense_7 (Dense) (None, 4) 68 \n", - " \n", - "=================================================================\n", - "Total params: 1,604\n", - "Trainable params: 1,604\n", - "Non-trainable params: 0\n", - "_________________________________________________________________\n", - "None\n" - ] - } - ], + "outputs": [], "source": [ "# Model Definition\n", "lstm_model = keras.Sequential()\n", @@ -1218,47 +1334,31 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ "# Model Training\n", - "lstm_loss = keras.losses.SparseCategoricalCrossentropy(from_logits=True)\n", - "lstm_optm = keras.optimizers.Adam(learning_rate=LSTM_LEARNING_RATE)\n", - "lstm_metrics = [tf.keras.metrics.SparseCategoricalCrossentropy(from_logits=True), tf.keras.metrics.Accuracy()]" + "lstm_loss = tf.losses.CategoricalCrossentropy(from_logits=True)\n", + "lstm_optm = tf.optimizers.Adam(learning_rate=LSTM_LEARNING_RATE)\n", + "lstm_metrics = [tf.keras.metrics.CategoricalCrossentropy(from_logits=True), tf.keras.metrics.BinaryCrossentropy(from_logits=True),tf.keras.metrics.Accuracy()]" ] }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Epoch 1/20\n" - ] - }, - { - "ename": "", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31mCanceled future for execute_request message before replies were done" - ] - }, - { - "ename": "", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31mThe Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click <a href='https://aka.ms/vscodeJupyterKernelCrash'>here</a> for more info. View Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details." + "9647/9647 [==============================] - 88s 9ms/step - loss: 0.6389 - categorical_crossentropy: 0.6388 - categorical_accuracy: 0.7669 - categorical_hinge: 0.5620 - val_loss: 0.2218 - val_categorical_crossentropy: 0.2217 - val_categorical_accuracy: 0.9551 - val_categorical_hinge: 0.2163\n" ] } ], "source": [ - "lstm_history = compile_and_fit(model=lstm_model, window=wg, loss= lstm_loss, optimizer= lstm_optm, metrics=lstm_metrics)" + "lstm_history = compile_and_fit(model=lstm_model, window=wg, epochs=1)" ] }, { @@ -1270,7 +1370,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ @@ -1280,24 +1380,55 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Model: \"sequential_8\"\n", + "_________________________________________________________________\n", + " Layer (type) Output Shape Param # \n", + "=================================================================\n", + " gru_7 (GRU) (None, 16) 1200 \n", + " \n", + " dense_14 (Dense) (None, 4) 68 \n", + " \n", + "=================================================================\n", + "Total params: 1,268\n", + "Trainable params: 1,268\n", + "Non-trainable params: 0\n", + "_________________________________________________________________\n", + "None\n" + ] + } + ], "source": [ - "gru_model = keras.Sequential([\n", - " layers.GRU(GRU_UNITS),\n", - " layers.Dense(SLEEP_STAGES)\n", - "])\n", - "gru_model.add(layers.Embedding(input_dim=1000, output_dim=64))\n", + "gru_model = keras.Sequential()\n", + "gru_model.add(layers.Input(shape=(INPUT_TIME_STEP, INPUT_FEATURES_SIZE)))\n", + "gru_model.add(layers.GRU(GRU_UNITS))\n", + "gru_model.add(layers.Dense(SLEEP_STAGES))\n", + "gru_model.build()\n", "print(gru_model.summary())" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9647/9647 [==============================] - 97s 10ms/step - loss: 0.4700 - categorical_crossentropy: 0.4700 - categorical_accuracy: 0.8416 - categorical_hinge: 0.4278 - val_loss: 0.2088 - val_categorical_crossentropy: 0.2087 - val_categorical_accuracy: 0.9595 - val_categorical_hinge: 0.1954\n" + ] + } + ], + "source": [ + "gru_history = compile_and_fit(model=gru_model, window=wg, epochs=1)" + ] }, { "cell_type": "markdown", @@ -1308,7 +1439,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ @@ -1317,23 +1448,55 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Model: \"sequential_10\"\n", + "_________________________________________________________________\n", + " Layer (type) Output Shape Param # \n", + "=================================================================\n", + " attention_1 (Attention) (None, 16) 273 \n", + " \n", + " dense_16 (Dense) (None, 4) 68 \n", + " \n", + "=================================================================\n", + "Total params: 341\n", + "Trainable params: 341\n", + "Non-trainable params: 0\n", + "_________________________________________________________________\n", + "None\n" + ] + } + ], "source": [ - "am_model = keras.Sequential([\n", - " Attention(ATTENTION_UNITS)\n", - " layers.Dense(SLEEP_STAGES)\n", - "])\n", + "am_model = keras.Sequential()\n", + "am_model.add(layers.Input(shape=(INPUT_TIME_STEP, INPUT_FEATURES_SIZE)))\n", + "am_model.add(Attention(ATTENTION_UNITS))\n", + "am_model.add(layers.Dense(SLEEP_STAGES))\n", + "am_model.build()\n", "print(am_model.summary())" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9647/9647 [==============================] - 52s 5ms/step - loss: 0.6620 - categorical_crossentropy: 0.6619 - categorical_accuracy: 0.7268 - categorical_hinge: 0.7192 - val_loss: 0.2141 - val_categorical_crossentropy: 0.2140 - val_categorical_accuracy: 0.9589 - val_categorical_hinge: 0.1990\n" + ] + } + ], + "source": [ + "am_history = compile_and_fit(model=am_model, window=wg, epochs=1)" + ] }, { "cell_type": "markdown",