Skip to content

Commit 145df95

Browse files
Multiple Attribute Support for Tensorflow Sparse and Dense Readers (#73)
* Mutliple attributes tensorflow dense * added functools partial to tensoroflow dense reader * minor change to from_generator output signature * tests fix tensorflow dense, pytorch dense, pytorch sparse * multi attribute tf sparse, tests fixed, extra tests added * changed tf reader example notebooks for multiple attribute compatibility * bound setuptools_scm * bound tensroflow version * tf sparse data api github issues added to tf sparse reader * PR changes
1 parent a2829e3 commit 145df95

10 files changed

+985
-458
lines changed

examples/readers/tensorflow_data_api_tiledb_dense.ipynb

+30-65
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"execution_count": 1,
1515
"metadata": {
1616
"pycharm": {
17+
"is_executing": true,
1718
"name": "#%%\n"
1819
}
1920
},
@@ -39,6 +40,7 @@
3940
"execution_count": 2,
4041
"metadata": {
4142
"pycharm": {
43+
"is_executing": true,
4244
"name": "#%%\n"
4345
}
4446
},
@@ -47,57 +49,9 @@
4749
"name": "stdout",
4850
"output_type": "stream",
4951
"text": [
50-
"[[[0. 0. 0. ... 0. 0. 0.]\n",
51-
" [0. 0. 0. ... 0. 0. 0.]\n",
52-
" [0. 0. 0. ... 0. 0. 0.]\n",
53-
" ...\n",
54-
" [0. 0. 0. ... 0. 0. 0.]\n",
55-
" [0. 0. 0. ... 0. 0. 0.]\n",
56-
" [0. 0. 0. ... 0. 0. 0.]]\n",
52+
"(60000, 28, 28)\n",
5753
"\n",
58-
" [[0. 0. 0. ... 0. 0. 0.]\n",
59-
" [0. 0. 0. ... 0. 0. 0.]\n",
60-
" [0. 0. 0. ... 0. 0. 0.]\n",
61-
" ...\n",
62-
" [0. 0. 0. ... 0. 0. 0.]\n",
63-
" [0. 0. 0. ... 0. 0. 0.]\n",
64-
" [0. 0. 0. ... 0. 0. 0.]]\n",
65-
"\n",
66-
" [[0. 0. 0. ... 0. 0. 0.]\n",
67-
" [0. 0. 0. ... 0. 0. 0.]\n",
68-
" [0. 0. 0. ... 0. 0. 0.]\n",
69-
" ...\n",
70-
" [0. 0. 0. ... 0. 0. 0.]\n",
71-
" [0. 0. 0. ... 0. 0. 0.]\n",
72-
" [0. 0. 0. ... 0. 0. 0.]]\n",
73-
"\n",
74-
" ...\n",
75-
"\n",
76-
" [[0. 0. 0. ... 0. 0. 0.]\n",
77-
" [0. 0. 0. ... 0. 0. 0.]\n",
78-
" [0. 0. 0. ... 0. 0. 0.]\n",
79-
" ...\n",
80-
" [0. 0. 0. ... 0. 0. 0.]\n",
81-
" [0. 0. 0. ... 0. 0. 0.]\n",
82-
" [0. 0. 0. ... 0. 0. 0.]]\n",
83-
"\n",
84-
" [[0. 0. 0. ... 0. 0. 0.]\n",
85-
" [0. 0. 0. ... 0. 0. 0.]\n",
86-
" [0. 0. 0. ... 0. 0. 0.]\n",
87-
" ...\n",
88-
" [0. 0. 0. ... 0. 0. 0.]\n",
89-
" [0. 0. 0. ... 0. 0. 0.]\n",
90-
" [0. 0. 0. ... 0. 0. 0.]]\n",
91-
"\n",
92-
" [[0. 0. 0. ... 0. 0. 0.]\n",
93-
" [0. 0. 0. ... 0. 0. 0.]\n",
94-
" [0. 0. 0. ... 0. 0. 0.]\n",
95-
" ...\n",
96-
" [0. 0. 0. ... 0. 0. 0.]\n",
97-
" [0. 0. 0. ... 0. 0. 0.]\n",
98-
" [0. 0. 0. ... 0. 0. 0.]]]\n",
99-
"\n",
100-
"[5 0 4 ... 5 6 8]\n"
54+
"(60000,)\n"
10155
]
10256
}
10357
],
@@ -106,9 +60,9 @@
10660
"(images, labels), _ = mnist.load_data()\n",
10761
"images = images / 255.0\n",
10862
"\n",
109-
"print(images)\n",
63+
"print(images.shape)\n",
11064
"print()\n",
111-
"print(labels)"
65+
"print(labels.shape)"
11266
]
11367
},
11468
{
@@ -128,6 +82,7 @@
12882
"execution_count": 3,
12983
"metadata": {
13084
"pycharm": {
85+
"is_executing": true,
13186
"name": "#%%\n"
13287
}
13388
},
@@ -175,6 +130,7 @@
175130
"execution_count": 4,
176131
"metadata": {
177132
"pycharm": {
133+
"is_executing": true,
178134
"name": "#%%\n"
179135
}
180136
},
@@ -199,6 +155,7 @@
199155
"execution_count": 5,
200156
"metadata": {
201157
"pycharm": {
158+
"is_executing": true,
202159
"name": "#%%\n"
203160
}
204161
},
@@ -209,9 +166,9 @@
209166
"text": [
210167
"ArraySchema(\n",
211168
" domain=Domain(*[\n",
212-
" Dim(name='dim_0', domain=(0, 59999), tile=64, dtype='int32'),\n",
213-
" Dim(name='dim_1', domain=(0, 27), tile=28, dtype='int32'),\n",
214-
" Dim(name='dim_2', domain=(0, 27), tile=28, dtype='int32'),\n",
169+
" Dim(name='dim_0', domain=(0, 59999), tile='64', dtype='int32'),\n",
170+
" Dim(name='dim_1', domain=(0, 27), tile='28', dtype='int32'),\n",
171+
" Dim(name='dim_2', domain=(0, 27), tile='28', dtype='int32'),\n",
215172
" ]),\n",
216173
" attrs=[\n",
217174
" Attr(name='features', dtype='float64', var=False, nullable=False),\n",
@@ -225,7 +182,7 @@
225182
"\n",
226183
"ArraySchema(\n",
227184
" domain=Domain(*[\n",
228-
" Dim(name='dim_0', domain=(0, 59999), tile=64, dtype='int32'),\n",
185+
" Dim(name='dim_0', domain=(0, 59999), tile='64', dtype='int32'),\n",
229186
" ]),\n",
230187
" attrs=[\n",
231188
" Attr(name='features', dtype='uint8', var=False, nullable=False),\n",
@@ -262,14 +219,15 @@
262219
"execution_count": 6,
263220
"metadata": {
264221
"pycharm": {
222+
"is_executing": true,
265223
"name": "#%%\n"
266224
}
267225
},
268226
"outputs": [
269227
{
270228
"data": {
271229
"text/plain": [
272-
"<matplotlib.image.AxesImage at 0x17ec58e50>"
230+
"<matplotlib.image.AxesImage at 0x175806510>"
273231
]
274232
},
275233
"execution_count": 6,
@@ -311,6 +269,7 @@
311269
"execution_count": 7,
312270
"metadata": {
313271
"pycharm": {
272+
"is_executing": true,
314273
"name": "#%%\n"
315274
}
316275
},
@@ -349,6 +308,7 @@
349308
"execution_count": 8,
350309
"metadata": {
351310
"pycharm": {
311+
"is_executing": true,
352312
"name": "#%%\n"
353313
}
354314
},
@@ -358,15 +318,15 @@
358318
"output_type": "stream",
359319
"text": [
360320
"Epoch 1/5\n",
361-
"938/938 [==============================] - 2s 1ms/step - loss: 0.3529 - accuracy: 0.8979\n",
321+
"938/938 [==============================] - 8s 8ms/step - loss: 0.3498 - accuracy: 0.9007\n",
362322
"Epoch 2/5\n",
363-
"938/938 [==============================] - 1s 1ms/step - loss: 0.1695 - accuracy: 0.9502\n",
323+
"938/938 [==============================] - 7s 8ms/step - loss: 0.1682 - accuracy: 0.9505\n",
364324
"Epoch 3/5\n",
365-
"938/938 [==============================] - 1s 1ms/step - loss: 0.1255 - accuracy: 0.9633\n",
325+
"938/938 [==============================] - 7s 8ms/step - loss: 0.1260 - accuracy: 0.9629\n",
366326
"Epoch 4/5\n",
367-
"938/938 [==============================] - 1s 995us/step - loss: 0.1036 - accuracy: 0.9683\n",
327+
"938/938 [==============================] - 7s 8ms/step - loss: 0.1028 - accuracy: 0.9697\n",
368328
"Epoch 5/5\n",
369-
"938/938 [==============================] - 1s 1ms/step - loss: 0.0847 - accuracy: 0.9743\n"
329+
"938/938 [==============================] - 8s 8ms/step - loss: 0.0853 - accuracy: 0.9746\n"
370330
]
371331
}
372332
],
@@ -375,7 +335,7 @@
375335
"\n",
376336
"with tiledb.open('training_images') as x, tiledb.open('training_labels') as y:\n",
377337
" tiledb_dataset = TensorflowTileDBDenseDataset(\n",
378-
" x_array=x, y_array=y, batch_size=64\n",
338+
" x_array=x, y_array=y, x_attribute_names=['features'], y_attribute_names=['features'], batch_size=64\n",
379339
" )\n",
380340
"\n",
381341
" model.fit(tiledb_dataset, epochs=5)"
@@ -386,6 +346,7 @@
386346
"execution_count": 9,
387347
"metadata": {
388348
"pycharm": {
349+
"is_executing": true,
389350
"name": "#%%\n"
390351
}
391352
},
@@ -420,7 +381,11 @@
420381
{
421382
"cell_type": "code",
422383
"execution_count": null,
423-
"metadata": {},
384+
"metadata": {
385+
"pycharm": {
386+
"is_executing": true
387+
}
388+
},
424389
"outputs": [],
425390
"source": []
426391
}
@@ -446,4 +411,4 @@
446411
},
447412
"nbformat": 4,
448413
"nbformat_minor": 1
449-
}
414+
}

0 commit comments

Comments
 (0)