Skip to main content

A Google Tensorflow MongoDB connector

Project description

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.


In order to use the dataset you need to install it with pip:

pip install tfmongodb


TFMongoDB can be accessed through the MongoDBDataset:

dataset = MongoDBDataset(<database_name>, <collection_name>)


from tfmongodb import MongoDBDataset
from tensorflow.python.framework import ops
from 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 =
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., feed_dict={})

    for i in range(5):

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
TFMongoDB-0.1.2-cp27-cp27m-macosx_10_13_x86_64.whl (65.1 kB) Copy SHA256 hash SHA256 Wheel cp27

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page