started implementing sliding window

master
Tuan-Dat Tran 2021-07-14 10:27:20 +02:00
parent f06f61cd04
commit ece9e8339e
1 changed files with 166 additions and 80 deletions

View File

@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "9aa64ac0",
"id": "a33b4ae2",
"metadata": {},
"outputs": [],
"source": [
@ -16,7 +16,7 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "d312c8e1",
"id": "bfcb55c8",
"metadata": {},
"outputs": [],
"source": [
@ -28,7 +28,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "c04ba7f6",
"id": "7bb04d71",
"metadata": {
"tags": []
},
@ -74,7 +74,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "45e23af8",
"id": "9adc333e",
"metadata": {},
"outputs": [],
"source": [
@ -89,7 +89,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "31a7d280",
"id": "dfc32785",
"metadata": {},
"outputs": [],
"source": [
@ -104,7 +104,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "ec0dd3cb",
"id": "09a66223",
"metadata": {},
"outputs": [
{
@ -140,7 +140,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "2d11eb89",
"id": "07df007d",
"metadata": {
"tags": []
},
@ -594,7 +594,7 @@
{
"cell_type": "code",
"execution_count": 81,
"id": "9ee5b898",
"id": "8d956063",
"metadata": {
"tags": []
},
@ -1052,8 +1052,8 @@
},
{
"cell_type": "code",
"execution_count": 82,
"id": "083ba677",
"execution_count": 95,
"id": "97c3ba71",
"metadata": {
"tags": []
},
@ -1106,8 +1106,8 @@
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-0.089895</td>\n",
" <td>1.755665</td>\n",
" <td>0.234344</td>\n",
@ -1130,8 +1130,8 @@
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-0.089738</td>\n",
" <td>1.755732</td>\n",
" <td>0.234542</td>\n",
@ -1154,8 +1154,8 @@
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-0.089347</td>\n",
" <td>1.755780</td>\n",
" <td>0.234738</td>\n",
@ -1178,8 +1178,8 @@
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-0.088938</td>\n",
" <td>1.755686</td>\n",
" <td>0.234353</td>\n",
@ -1202,8 +1202,8 @@
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>-0.088715</td>\n",
" <td>1.755643</td>\n",
" <td>0.234471</td>\n",
@ -1250,8 +1250,8 @@
" <tr>\n",
" <th>2020</th>\n",
" <td>2020</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.067835</td>\n",
" <td>1.149886</td>\n",
" <td>0.087708</td>\n",
@ -1274,8 +1274,8 @@
" <tr>\n",
" <th>2021</th>\n",
" <td>2021</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.076106</td>\n",
" <td>1.142307</td>\n",
" <td>0.086917</td>\n",
@ -1298,8 +1298,8 @@
" <tr>\n",
" <th>2022</th>\n",
" <td>2022</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.085397</td>\n",
" <td>1.135880</td>\n",
" <td>0.086078</td>\n",
@ -1322,8 +1322,8 @@
" <tr>\n",
" <th>2023</th>\n",
" <td>2023</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.096437</td>\n",
" <td>1.129293</td>\n",
" <td>0.084847</td>\n",
@ -1346,8 +1346,8 @@
" <tr>\n",
" <th>2024</th>\n",
" <td>2024</td>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.106890</td>\n",
" <td>1.123694</td>\n",
" <td>0.084149</td>\n",
@ -1374,17 +1374,17 @@
],
"text/plain": [
" Unnamed: 0 LeftHandTrackingAccuracy RightHandTrackingAccuracy \\\n",
"0 0 1.0 1.0 \n",
"1 1 1.0 1.0 \n",
"2 2 1.0 1.0 \n",
"3 3 1.0 1.0 \n",
"4 4 1.0 1.0 \n",
"0 0 0.0 0.0 \n",
"1 1 0.0 0.0 \n",
"2 2 0.0 0.0 \n",
"3 3 0.0 0.0 \n",
"4 4 0.0 0.0 \n",
"... ... ... ... \n",
"2020 2020 1.0 1.0 \n",
"2021 2021 1.0 1.0 \n",
"2022 2022 1.0 1.0 \n",
"2023 2023 1.0 1.0 \n",
"2024 2024 1.0 1.0 \n",
"2020 2020 0.0 0.0 \n",
"2021 2021 0.0 0.0 \n",
"2022 2022 0.0 0.0 \n",
"2023 2023 0.0 0.0 \n",
"2024 2024 0.0 0.0 \n",
"\n",
" CenterEyeAnchor_pos_X CenterEyeAnchor_pos_Y CenterEyeAnchor_pos_Z \\\n",
"0 -0.089895 1.755665 0.234344 \n",
@ -1493,7 +1493,7 @@
"[2025 rows x 339 columns]"
]
},
"execution_count": 82,
"execution_count": 95,
"metadata": {},
"output_type": "execute_result"
}
@ -1512,31 +1512,24 @@
},
{
"cell_type": "code",
"execution_count": 83,
"id": "00edea73",
"metadata": {},
"outputs": [],
"source": [
"# d_entry = c_entry.where(c_entry['LeftHandTrackingAccuracy'] == c_entry['RightHandTrackingAccuracy']).dropna().reset_index(drop=True)\n",
"# a = entry.copy()\n",
"# a['data'] = d_entry.drop(droptable, axis=1)\n",
"# print(a['data'].shape)\n",
"# print(a['data'].dtypes)"
]
},
{
"cell_type": "code",
"execution_count": 84,
"id": "547f63d2",
"execution_count": 96,
"id": "7ab1aa62",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(2025, 339)\n"
]
},
{
"data": {
"text/plain": [
"<BatchDataset shapes: ((None, None, 2100), (None,)), types: (tf.float64, tf.int32)>"
]
},
"execution_count": 84,
"execution_count": 96,
"metadata": {},
"output_type": "execute_result"
}
@ -1547,8 +1540,8 @@
"\n",
"def slicing(entry):\n",
" stride = 150\n",
" \n",
" entry['data'] = pad_sequences(entry['data'].to_numpy().T,\n",
" print(entry['data'].to_numpy().shape)\n",
" entry['data'] = pad_sequences(entry['data'].to_numpy(),\n",
" maxlen=(int(entry['data'].shape[0]/stride)+1)*stride,\n",
" dtype='float64',\n",
" padding='pre', truncating='post'\n",
@ -1570,8 +1563,8 @@
},
{
"cell_type": "code",
"execution_count": 86,
"id": "620c529b",
"execution_count": 97,
"id": "8827bbab",
"metadata": {},
"outputs": [
{
@ -1579,19 +1572,112 @@
"output_type": "stream",
"text": [
"tf.Tensor(\n",
"[[[ 0.000000e+00 0.000000e+00 0.000000e+00 ... 2.022000e+03\n",
" 2.023000e+03 2.024000e+03]\n",
" [ 0.000000e+00 0.000000e+00 0.000000e+00 ... 1.000000e+00\n",
" 1.000000e+00 1.000000e+00]\n",
" [ 0.000000e+00 0.000000e+00 0.000000e+00 ... 1.000000e+00\n",
" 1.000000e+00 1.000000e+00]\n",
"[[[ 0. 0. 0. ... 310.8786 343.5717 185.1874]\n",
" [ 0. 0. 0. ... 311.1056 343.7456 185.6717]\n",
" [ 0. 0. 0. ... 311.2307 343.7971 185.9125]\n",
" ...\n",
" [ 0.000000e+00 0.000000e+00 0.000000e+00 ... 1.247579e+00\n",
" 1.257665e+00 1.273240e+00]\n",
" [ 0.000000e+00 0.000000e+00 0.000000e+00 ... 6.340001e-01\n",
" 6.261733e-01 6.128760e-01]\n",
" [ 0.000000e+00 0.000000e+00 0.000000e+00 ... -8.997461e-02\n",
" -8.650930e-02 -8.193973e-02]]], shape=(1, 300, 2100), dtype=float64)\n",
" [ 0. 0. 0. ... 334.9102 105.7513 287.5223]\n",
" [ 0. 0. 0. ... 334.6709 104.5253 287.9581]\n",
" [ 0. 0. 0. ... 334.5766 103.5059 288.4085]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 337.3954 115.2253 239.2146 ]\n",
" [ 0. 0. 0. ... 337.7683 115.3956 240.4796 ]\n",
" [ 0. 0. 0. ... 338.0132 115.4679 241.2587 ]\n",
" ...\n",
" [ 0. 0. 0. ... 332.9107 41.93251 124.3949 ]\n",
" [ 0. 0. 0. ... 333.1059 40.51485 124.8919 ]\n",
" [ 0. 0. 0. ... 332.9174 39.48595 125.2935 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 334.441 102.5691 288.6859]\n",
" [ 0. 0. 0. ... 334.4541 101.1844 290.0429]\n",
" [ 0. 0. 0. ... 334.5445 100.4508 291.0764]\n",
" ...\n",
" [ 0. 0. 0. ... 342.0367 322.5176 287.4604]\n",
" [ 0. 0. 0. ... 341.5087 322.9041 288.0399]\n",
" [ 0. 0. 0. ... 341.0814 323.1584 288.53 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 332.7831 38.47573 125.6316 ]\n",
" [ 0. 0. 0. ... 332.4827 36.4628 126.487 ]\n",
" [ 0. 0. 0. ... 332.2903 35.13992 127.0712 ]\n",
" ...\n",
" [ 0. 0. 0. ... 358.9955 91.98264 223.499 ]\n",
" [ 0. 0. 0. ... 358.6208 91.1073 225.3601 ]\n",
" [ 0. 0. 0. ... 358.354 90.26964 227.1508 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 340.7549 323.3292 289.6002 ]\n",
" [ 0. 0. 0. ... 340.5391 323.4655 290.4398 ]\n",
" [ 0. 0. 0. ... 340.3628 323.5816 291.6447 ]\n",
" ...\n",
" [ 0. 0. 0. ... 334.6424 149.6268 96.6635 ]\n",
" [ 0. 0. 0. ... 335.1271 151.0876 96.39161]\n",
" [ 0. 0. 0. ... 335.5759 152.4971 96.23958]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 358.0558 89.08697 228.282 ]\n",
" [ 0. 0. 0. ... 357.9095 88.468 228.3914 ]\n",
" [ 0. 0. 0. ... 357.7622 87.76212 228.7186 ]\n",
" ...\n",
" [ 0. 0. 0. ... 350.4678 191.8058 293.6591 ]\n",
" [ 0. 0. 0. ... 349.4155 191.758 290.0341 ]\n",
" [ 0. 0. 0. ... 348.4454 191.7047 286.47 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 336.1516 154.5288 95.77281 ]\n",
" [ 0. 0. 0. ... 336.4283 155.5994 95.43106 ]\n",
" [ 0. 0. 0. ... 336.7111 156.6993 95.16699 ]\n",
" ...\n",
" [ 0. 0. 0. ... 1.877451 189.7006 176.2247 ]\n",
" [ 0. 0. 0. ... 2.298272 189.6146 174.1894 ]\n",
" [ 0. 0. 0. ... 2.357256 189.587 173.9407 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 347.4656 193.364 277.8619 ]\n",
" [ 0. 0. 0. ... 347.1607 194.9414 272.1756 ]\n",
" [ 0. 0. 0. ... 346.816 196.2879 266.7031 ]\n",
" ...\n",
" [ 0. 0. 0. ... 328.2634 195.3502 53.96029]\n",
" [ 0. 0. 0. ... 328.1786 200.2938 56.4752 ]\n",
" [ 0. 0. 0. ... 328.5285 204.5934 59.88613]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 2.574736 189.5766 172.9151 ]\n",
" [ 0. 0. 0. ... 2.947406 189.6876 171.4222 ]\n",
" [ 0. 0. 0. ... 3.538999 190.0329 169.4787 ]\n",
" ...\n",
" [ 0. 0. 0. ... 339.8397 195.9552 144.3933 ]\n",
" [ 0. 0. 0. ... 339.8964 192.4409 148.1278 ]\n",
" [ 0. 0. 0. ... 340.1847 190.5611 150.9379 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 328.807 209.356 64.13982]\n",
" [ 0. 0. 0. ... 329.1744 219.1686 82.03358]\n",
" [ 0. 0. 0. ... 328.9293 224.907 95.42315]\n",
" ...\n",
" [ 0. 0. 0. ... 311.8901 182.3479 207.4501 ]\n",
" [ 0. 0. 0. ... 296.0581 43.59404 291.2405 ]\n",
" [ 0. 0. 0. ... 296.0581 43.59404 291.2405 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 340.4522 188.5802 153.4675]\n",
" [ 0. 0. 0. ... 342.0439 186.2218 158.3235]\n",
" [ 0. 0. 0. ... 343.4704 184.4892 161.9352]\n",
" ...\n",
" [ 0. 0. 0. ... 336.0501 100.8427 308.4322]\n",
" [ 0. 0. 0. ... 336.5646 102.0053 307.9174]\n",
" [ 0. 0. 0. ... 336.9454 102.9008 307.495 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n",
"tf.Tensor(\n",
"[[[ 0. 0. 0. ... 296.0581 43.59404 291.2405 ]\n",
" [ 0. 0. 0. ... 318.9684 302.7743 264.226 ]\n",
" [ 0. 0. 0. ... 318.9684 302.7743 264.226 ]\n",
" ...\n",
" [ 0. 0. 0. ... 321.3094 67.3396 295.069 ]\n",
" [ 0. 0. 0. ... 321.406 66.64935 293.5298 ]\n",
" [ 0. 0. 0. ... 321.696 65.39925 291.8149 ]]], shape=(1, 300, 2100), dtype=float64)\n",
"tf.Tensor([7], shape=(1,), dtype=int32)\n"
]
}
@ -1605,7 +1691,7 @@
{
"cell_type": "code",
"execution_count": 126,
"id": "4e755031",
"id": "bcec87a9",
"metadata": {},
"outputs": [
{
@ -1640,7 +1726,7 @@
{
"cell_type": "code",
"execution_count": 98,
"id": "d4207627",
"id": "fb10decc",
"metadata": {},
"outputs": [],
"source": [
@ -1652,7 +1738,7 @@
{
"cell_type": "code",
"execution_count": 110,
"id": "e068b158",
"id": "08ae9f52",
"metadata": {},
"outputs": [
{
@ -1690,7 +1776,7 @@
{
"cell_type": "code",
"execution_count": 111,
"id": "84260e81",
"id": "57fee43e",
"metadata": {},
"outputs": [
{
@ -1730,7 +1816,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "c4cbcf14",
"id": "69bd85a5",
"metadata": {},
"outputs": [],
"source": [
@ -1748,7 +1834,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3f5d854e",
"id": "522518bc",
"metadata": {},
"outputs": [],
"source": [