Commit c1661dc9 authored by Kaan Güney Keklikçi's avatar Kaan Güney Keklikçi

correct ks-test for nice

parent 8506e8f4
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 198, "execution_count": 200,
"id": "9f0b013a", "id": "9f0b013a",
"metadata": { "metadata": {
"scrolled": true "scrolled": true
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
" (0.7775608374378459, 0.8840392521212448, 0.9452007992345052)]" " (0.7775608374378459, 0.8840392521212448, 0.9452007992345052)]"
] ]
}, },
"execution_count": 198, "execution_count": 200,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
"from tensorflow.keras.layers import Dense, Flatten, Reshape, Input, BatchNormalization\n", "from tensorflow.keras.layers import Dense, Flatten, Reshape, Input, BatchNormalization\n",
"from tensorflow.keras.losses import Loss\n", "from tensorflow.keras.losses import Loss\n",
"import scipy\n", "import scipy\n",
"import ks2d2s\n", "from ks2d2s import ks2d2s\n",
"\n", "\n",
"tfd = tfp.distributions\n", "tfd = tfp.distributions\n",
"tfb = tfp.bijectors\n", "tfb = tfp.bijectors\n",
...@@ -1359,18 +1359,22 @@ ...@@ -1359,18 +1359,22 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 197, "execution_count": 226,
"id": "b31a919e", "id": "b31a919e",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# KS-test\n", "# KS-test\n",
"prior_sample = prior.sample(X_train_copy.shape[0]).numpy()\n", "prior_sample = prior.sample(X_train_copy.shape[0]).numpy()\n",
"post_sample = trainable_dist.sample(X_train_copy.shape[0]).numpy()\n",
"\n", "\n",
"with open('ks-test.txt', 'a') as f:\n", "with open('ks-test.txt', 'a') as f:\n",
" f.write('NICE FLOW\\n')\n", " f.write('NICE FLOW\\n')\n",
" f.write('p-val[prior - target] = {}\\n'.format(ks2d2s(X_train_copy['PRE4'], X_train_copy['PRE5'],prior_sample[...,0], prior_sample[...,1])))\n", " f.write('p-val[training - qtrainable] = {}\\n'.format(ks2d2s(X_train_np[...,0], X_train_np[...,1], prior_sample[...,0], prior_sample[...,1])))\n",
" f.write('p-val[trained - target] = {}\\n'.format(ks2d2s(X_train_copy['PRE4'], X_train_copy['PRE5'],samples['PRE4'], samples['PRE5'])))\n", " f.write('p-val[training - qtrained] = {}\\n'.format(ks2d2s(X_train_np[...,0], X_train_np[...,1], post_sample[...,0], post_sample[...,1])))\n",
" \n",
" f.write('p-val[testing - qtrainable] = {}\\n'.format(ks2d2s(X_test_np[...,0], X_test_np[...,1], prior_sample[...,0], prior_sample[...,1])))\n",
" f.write('p-val[testing - qtrained] = {}\\n'.format(ks2d2s(X_test_np[...,0], X_test_np[...,1], post_sample[...,0], post_sample[...,1])))\n",
"f.close()" "f.close()"
] ]
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment