{ "info": { "author": "Cristian Garcia", "author_email": "cgarcia.e88@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Tensor Builder\nTensorBuilder is a TensorFlow-based library that enables you to easily create complex neural networks using functional programming.\n\n##Import\n\nFor demonstration purposes we will import right now everything we will need for the rest of the exercises like this\n```python\nfrom tensorbuilder.api import *\nimport tensorflow as tf\n```\nbut you can also import just what you need from the `tensorbuilder` module.\n\n## Phi\n#### Lambdas\nWith the `T` object you can create quick math-like lambdas using any operator, this lets you write things like\n```python\nx, b = tf.placeholder('float'), tf.placeholder('float')\n\nf = (T + b) / (T + 10) #lambda x: (x + b) / (x + 10)\ny = f(x)\n\nassert \"div\" in y.name\n```\n\n#### Composition\nUse function composition with the `>>` operator to improve readability\n```python\nx, w, b = tf.placeholder('float', [None, 5]), tf.placeholder('float', [5, 3]), tf.placeholder('float', [3])\n\nf = T.matmul(w) >> T + b >> T.sigmoid()\ny = f(x)\n\nassert \"Sigmoid\" in y.name\n```\n\n## tf + nn\nAny function from the `tf` and `nn` modules is a method from the `T` object, as before you can use the `>>` operator or you can chain them to produce complex functions\n```python\nx, w, b = tf.placeholder('float', [None, 5]), tf.placeholder('float', [5, 3]), tf.placeholder('float', [3])\n\nf = T.matmul(w).add(b).sigmoid()\ny = f(x)\n\nassert \"Sigmoid\" in y.name\n```\n## layers\n#### affine\nYou can use functions from the `tf.contrib.layers` module via the `T.layers` property. Here we will use [Pipe](https://github.com/cgarciae/phi#seq-and-pipe) to apply a value directly to an expression:\n```python\nx = tf.placeholder('float', [None, 5])\n\ny = Pipe(\n x,\n T.layers.fully_connected(64, activation_fn=tf.nn.sigmoid) # sigmoid layer 64\n .layers.fully_connected(32, activation_fn=tf.nn.tanh) # tanh layer 32\n .layers.fully_connected(16, activation_fn=None) # linear layer 16\n .layers.fully_connected(8, activation_fn=tf.nn.relu) # relu layer 8\n)\n\nassert \"Relu\" in y.name\n```\nHowever, since it is such a common task to build fully_connected layers using the different functions from the `tf.nn` module, we've (dynamically) create all combination of these as their own methods so you con rewrite the previous as\n```python\nx = tf.placeholder('float', [None, 5])\n\ny = Pipe(\n x,\n T.sigmoid_layer(64) # sigmoid layer 64\n .tanh_layer(32) # tanh layer 32\n .linear_layer(16) # linear layer 16\n .relu_layer(8) # relu layer 8\n)\n\nassert \"Relu\" in y.name\n```\nThe latter is much more compact, English readable, and reduces a lot of noise.\n\n#### convolutional\nComing soon!\n\n## leveraging phi\nComing soon!\n\n## summary\nComing soon!\n\n## other ops\nComing soon!\n\n## Installation\nTensor Builder assumes you have a working `tensorflow` installation. We don't include it in the `requirements.txt` since the installation of tensorflow varies depending on your setup.\n\n#### From pypi\n```\npip install tensorbuilder\n```\n\n#### From github\nFor the latest development version\n```\npip install git+https://github.com/cgarciae/tensorbuilder.git@develop\n```\n\n## Getting Started\n\nCreate neural network with a [5, 10, 3] architecture with a `softmax` output layer and a `tanh` hidden layer through a Builder and then get back its tensor:\n\n```python\nimport tensorflow as tf\nfrom tensorbuilder import T\n\nx = tf.placeholder(tf.float32, shape=[None, 5])\nkeep_prob = tf.placeholder(tf.float32)\n\nh = T.Pipe(\n x,\n T.tanh_layer(10) # tanh(x * w + b)\n .dropout(keep_prob) # dropout(x, keep_prob)\n .softmax_layer(3) # softmax(x * w + b)\n)\n```\n\n## Features\nComming Soon!\n\n## Documentation\nComming Soon!\n\n## The Guide\nComming Soon!\n\n## Full Example\nNext is an example with all the features of TensorBuilder including the DSL, branching and scoping. It creates a branched computation where each branch is executed on a different device. All branches are then reduced to a single layer, but the computation is the branched again to obtain both the activation function and the trainer.\n\n```python\nimport tensorflow as tf\nfrom tensorbuilder import T\n\nx = placeholder(tf.float32, shape=[None, 10])\ny = placeholder(tf.float32, shape=[None, 5])\n\n[activation, trainer] = T.Pipe(\n x,\n [\n T.With( tf.device(\"/gpu:0\"):\n T.relu_layer(20)\n )\n ,\n T.With( tf.device(\"/gpu:1\"):\n T.sigmoid_layer(20)\n )\n ,\n T.With( tf.device(\"/cpu:0\"):\n T.tanh_layer(20)\n )\n ],\n T.linear_layer(5),\n [\n T.softmax() # activation\n ,\n T\n .softmax_cross_entropy_with_logits(y) # loss\n .minimize(tf.train.AdamOptimizer(0.01)) # trainer\n ]\n)\n```", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/cgarciae/tensorbuilder/tarball/0.3.6", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cgarciae/tensorbuilder", "keywords": "tensorflow,deep learning,neural networks", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "tensorbuilder", "package_url": "https://pypi.org/project/tensorbuilder/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/tensorbuilder/", "project_urls": { "Download": "https://github.com/cgarciae/tensorbuilder/tarball/0.3.6", "Homepage": "https://github.com/cgarciae/tensorbuilder" }, "release_url": "https://pypi.org/project/tensorbuilder/0.3.6/", "requires_dist": null, "requires_python": null, "summary": "A light wrapper over TensorFlow that enables you to easily create complex deep neural networks using the Builder Pattern through a functional fluent immutable API", "version": "0.3.6" }, "last_serial": 2586740, "releases": { "0.0.10": [ { "comment_text": "", "digests": { "md5": "f9cc9deb85daad5854f9f981c8739b6d", "sha256": "9ad519f6de62d05a4114d8121de8d815dfe62c16c0d3921bd4b9d79c230db0fb" }, "downloads": -1, "filename": "tensorbuilder-0.0.10.tar.gz", "has_sig": false, "md5_digest": "f9cc9deb85daad5854f9f981c8739b6d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20548, "upload_time": "2016-08-29T01:04:31", "url": "https://files.pythonhosted.org/packages/ad/c9/ee50e759d87f505c4b76c1f240c62573dabe8a35bae435a508115e83f215/tensorbuilder-0.0.10.tar.gz" } ], "0.0.11": [ { "comment_text": "", "digests": { "md5": "e6ad5b4c451f389272b11a40cf78ab2b", "sha256": "a1dec8646f4cb9ebffe7d06acf93f5dfd49f6ca09f6f6efc1f8e83338fd5d157" }, "downloads": -1, "filename": "tensorbuilder-0.0.11.tar.gz", "has_sig": false, "md5_digest": "e6ad5b4c451f389272b11a40cf78ab2b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20556, "upload_time": "2016-08-29T01:07:32", "url": "https://files.pythonhosted.org/packages/85/09/c88f5209f130f7d0ad105e039b0afa74c380ef202636a49911b7d704fa23/tensorbuilder-0.0.11.tar.gz" } ], "0.0.12": [ { "comment_text": "", "digests": { "md5": "2c736bff6fc3b619b0b621112cde111c", "sha256": "89cf42a0df9e227588e8e3ac9fe9b00aa9de71d522267eb2545e7405906ebf43" }, "downloads": -1, "filename": "tensorbuilder-0.0.12.tar.gz", "has_sig": false, "md5_digest": "2c736bff6fc3b619b0b621112cde111c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20564, "upload_time": "2016-08-29T01:10:29", "url": "https://files.pythonhosted.org/packages/58/d3/be8ecf4c3a41c6ea138928ae7d686a0288f70a99f3f4648bcb1ef4f790e6/tensorbuilder-0.0.12.tar.gz" } ], "0.0.13": [ { "comment_text": "", "digests": { "md5": "50ee87864ef6a19000f3fefaf5c2e751", "sha256": "f900e26ae7d109b7028396c74578965c33c59d81189884dcf34c5e28ac340546" }, "downloads": -1, "filename": "tensorbuilder-0.0.13.tar.gz", "has_sig": false, "md5_digest": "50ee87864ef6a19000f3fefaf5c2e751", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20614, "upload_time": "2016-08-29T01:14:28", "url": "https://files.pythonhosted.org/packages/c2/66/2cb4f75afb99c6b57888b0944d292de3219729aeffa761ade28102791dde/tensorbuilder-0.0.13.tar.gz" } ], "0.0.14": [ { "comment_text": "", "digests": { "md5": "1b9937a17214778d0b8e43b01716fcb4", "sha256": "a9673507bbe3351775cc4818b75bbe9cdfbf57a9682c04b938312e005ab320e9" }, "downloads": -1, "filename": "tensorbuilder-0.0.14.tar.gz", "has_sig": false, "md5_digest": "1b9937a17214778d0b8e43b01716fcb4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20613, "upload_time": "2016-08-29T01:16:03", "url": "https://files.pythonhosted.org/packages/13/79/4c5ecc088dbab1f92f34411938330f611d53dab3a5558dd1b59add047eb2/tensorbuilder-0.0.14.tar.gz" } ], "0.0.15": [ { "comment_text": "", "digests": { "md5": "b7e1282e9674e61655fee9f492fb442b", "sha256": "8d1ae2c05e3bb94149d3ec8b87eeaa3402a5e25777d6737c625ddb289d6f3d80" }, "downloads": -1, "filename": "tensorbuilder-0.0.15.tar.gz", "has_sig": false, "md5_digest": "b7e1282e9674e61655fee9f492fb442b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21551, "upload_time": "2016-08-29T01:20:22", "url": "https://files.pythonhosted.org/packages/f6/86/1e44d8d375c9aacfe1db406e66bb3217e1eab2da98e51a3e6a6d77e4e7c4/tensorbuilder-0.0.15.tar.gz" } ], "0.0.16": [ { "comment_text": "", "digests": { "md5": "e0c8ec712adcbb6ad3a94d3a3679f4de", "sha256": "94842ea499332eb6618d1019ab1198b22090d5207353656820ba23f983637b11" }, "downloads": -1, "filename": "tensorbuilder-0.0.16.tar.gz", "has_sig": false, "md5_digest": "e0c8ec712adcbb6ad3a94d3a3679f4de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21899, "upload_time": "2016-11-07T17:18:55", "url": "https://files.pythonhosted.org/packages/7a/27/ca430675ec3ec77d0eb6c495a27f1fc7a3ed73e5613733507518433b4c5a/tensorbuilder-0.0.16.tar.gz" } ], "0.0.17": [ { "comment_text": "", "digests": { "md5": "b7ba3a0b318e43ecdd5bc39668cdd435", "sha256": "130835548c97332ad66450b821325fba881401e31f50d205c812f157ecab51ca" }, "downloads": -1, "filename": "tensorbuilder-0.0.17.tar.gz", "has_sig": false, "md5_digest": "b7ba3a0b318e43ecdd5bc39668cdd435", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21953, "upload_time": "2016-11-07T17:48:40", "url": "https://files.pythonhosted.org/packages/a0/a4/f7fb801b21bd3ba646addaac685a3a083abe97a57bb70ded30f0d530ca61/tensorbuilder-0.0.17.tar.gz" } ], "0.0.18": [ { "comment_text": "", "digests": { "md5": "9741441a619de5c5fe1a5511f88c39ae", "sha256": "694b8a4025f25aa5464277cbc9ef99ee9ef35e110c323f1b3fd63642d9a0ea0f" }, "downloads": -1, "filename": "tensorbuilder-0.0.18.tar.gz", "has_sig": false, "md5_digest": "9741441a619de5c5fe1a5511f88c39ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23301, "upload_time": "2016-11-07T18:07:15", "url": "https://files.pythonhosted.org/packages/58/ba/b22693a213ee3c6a9e891d50eac1090697ce6079903b9c342bb8052061fc/tensorbuilder-0.0.18.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "f38a45a7e6e1a46a30de2f47c93038d8", "sha256": "94b3468a162ebc7cf245e7c6d5587affa53aa72468cbb3467a88184be045be51" }, "downloads": -1, "filename": "tensorbuilder-0.0.9.tar.gz", "has_sig": false, "md5_digest": "f38a45a7e6e1a46a30de2f47c93038d8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20628, "upload_time": "2016-08-29T00:49:03", "url": "https://files.pythonhosted.org/packages/de/89/a6ca7ccdc7a7f8350accb2ff89f9bc626786901bc2cb8e5119d80f2ca922/tensorbuilder-0.0.9.tar.gz" } ], "0.2.5": [ { "comment_text": "", "digests": { "md5": "1a0200e41c95ed8b92b8a0e9dc0c047d", "sha256": "58419adaae254c4af9948b6626d3cfa49025a163244271314c5e2ae1bd52d857" }, "downloads": -1, "filename": "tensorbuilder-0.2.5.tar.gz", "has_sig": false, "md5_digest": "1a0200e41c95ed8b92b8a0e9dc0c047d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8759, "upload_time": "2016-12-12T15:29:14", "url": "https://files.pythonhosted.org/packages/8c/dc/7866a2abf27b8b8d94ecfc831c93dcb0f75da4083efa3b968cb2243f479b/tensorbuilder-0.2.5.tar.gz" } ], "0.3.6": [ { "comment_text": "", "digests": { "md5": "1fc094711a16a71fdb7877d06cb43b85", "sha256": "eee7abd0c2393225fdba5ccbbd619f327eaf0c0e0bec9a4c0d01a573d9615f8e" }, "downloads": -1, "filename": "tensorbuilder-0.3.6.tar.gz", "has_sig": false, "md5_digest": "1fc094711a16a71fdb7877d06cb43b85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11535, "upload_time": "2017-01-20T04:28:14", "url": "https://files.pythonhosted.org/packages/b5/36/6d0bf558b9307c2e89f44a5b97c3f2921defc98b0cd70b556ceec83eedad/tensorbuilder-0.3.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1fc094711a16a71fdb7877d06cb43b85", "sha256": "eee7abd0c2393225fdba5ccbbd619f327eaf0c0e0bec9a4c0d01a573d9615f8e" }, "downloads": -1, "filename": "tensorbuilder-0.3.6.tar.gz", "has_sig": false, "md5_digest": "1fc094711a16a71fdb7877d06cb43b85", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11535, "upload_time": "2017-01-20T04:28:14", "url": "https://files.pythonhosted.org/packages/b5/36/6d0bf558b9307c2e89f44a5b97c3f2921defc98b0cd70b556ceec83eedad/tensorbuilder-0.3.6.tar.gz" } ] }