TFMongoDB is a C++ implemented dataset op for google’s tensorflow that allows you to connect to your MongoDatabase natively. Hence you can access your mongodb stored documents more efficiently.
Currently only MacOS X is supported while Tensorflow >= 1.5 is required.
Installation
In order to use the dataset you need to install it with pip:
pip install tfmongodb
Usage
TFMongoDB can be accessed through the MongoDBDataset:
dataset = MongoDBDataset(<database_name>, <collection_name>)
example:
from tfmongodb import MongoDBDataset
from tensorflow.python.framework import ops
from tensorflow.python.data.ops import iterator_ops
import tensorflow as tf
CSV_TYPES = [[""], [""], [0]]
def _parse_line(line):
fields = tf.decode_csv(line, record_defaults=CSV_TYPES)
return fields
dataset = MongoDBDataset("eccounting", "creditors")
dataset = dataset.map(_parse_line)
repeat_dataset2 = dataset.repeat()
batch_dataset = repeat_dataset2.batch(20)
iterator = iterator_ops.Iterator.from_structure(batch_dataset.output_types)
#init_op = iterator.make_initializer(dataset)
init_batch_op = iterator.make_initializer(batch_dataset)
get_next = iterator.get_next()
with tf.Session() as sess:
# Basic test: read from topic 0.
sess.run(init_batch_op, feed_dict={})
for i in range(5):
print(sess.run(get_next))
Release files for TFMongoDB 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| TFMongoDB-0.1.3-cp37-cp37m-macosx_10_14_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | macOS 10.14+ x86-64 | Details |
Release files / TFMongoDB-0.1.3-cp37-cp37m-macosx_10_14_x86_64.whl
| Download URL | TFMongoDB-0.1.3-cp37-cp37m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 73.5 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
af0c1f00a5508f0af5750adcc35f1400ed35c5b8eda3878d6a5f420957823b29
|
|
BLAKE2b-256 checksum How to use checksums |
313394a4f16ff19abaf288297096ec02498770a79cb943d3f7678884e7f2892c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|