Skip to main content

TensorFlow Wrapper

Project description

The Canton library is a lightweight wrapper around TensorFlow, focused on intuitive programmatical modeling and weight sharing. It provides flexible ways to define, train, evaluate and save your computational networks.

Canton is named after the city of Guangzhou. The French came a long time ago; they used to call this city “Canton”, which sounds like “Guangdong” when pronounced in French, which is actually the name of the province, not the city. Since then, all westerners start to use the word Canton. The Yue language, a dialect of Chinese commonly used in Guangzhou and the United States, is known as “Cantonese” in English for this reason.

The Canton Philosophy

  • The network units, and the weights associated with them, should be tied together as one, not seperated.

  • Therefore, obtaining the weight tensors of any weighted action (or a set of actions bound together, or a network) should be as easy as calling some_action.get_weights(), not tf.very_long_method_name(some_collection).some_other_method(some_name_prefixes).

  • One should by default be able to create a unit once and apply it everywhere, while maintaining only one set of weights for that unit.

Usage

Check this tutorial.

No explicit documentation. Please consider reading the source code (only 3 files).

Story Behind

TensorFlow is cool in general, but some of its designs are disasterous. The official way to share variables(weights) between copies of networks is to use tf.variable_scope(scopename, reuse=True) and tf.get_variable(name). It then became the programmer’s responsibility to specify(and keep track of) the scope names, variable names and flags. As a programmer, I soon realized that There are only two hard things in Computer Science: cache invalidation and naming things.

TensorFlow is from Google, where CS PhDs write all the code, so that mustn’t be their problem. In order to deal with my own incompetence, I wrote this library.

Keras also wrapped the quirks and weirdness of TensorFlow and allows for rapid prototyping, but if you want to introduce your own calculation and/or manipulation operations into the model, you must first inherit Keras’ Layer class, then (in some cases) specify a shape inference function, which is boring and inefficient. Besides that, Keras does not support anything other than the kaggle-styled, input-to-output-chained, one-loss-updates-everything architecture. I tried various method to wrap aroud Keras(in order to add my own functionality), but the internal complexity of Keras continuously freaked me off(I read almost every page of its documentation and half its code).

Other learning frameworks also made various attempts on solving the same problem, using fancy descriptions like “imperative vs declarative”. Well, maybe they do need a lot of PhDs to solve the second hardest thing in Computer Science…

Install

pip install canton

Support Python 3 only.

dependencies:

  • tensorflow-1.0.0

Project details


Download files

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

Source Distribution

canton-0.1.15.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

canton-0.1.15-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file canton-0.1.15.tar.gz.

File metadata

  • Download URL: canton-0.1.15.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for canton-0.1.15.tar.gz
Algorithm Hash digest
SHA256 efbb8505158f02d9bb87da60168075b8474a5b91c091b216bc9f45a5b6a8d09a
MD5 c273214a9ded796aafdab0c378edeb28
BLAKE2b-256 86abff50be418bbc0e34ef6194ce0585519d7925c79f24ffc4fcf2476838d4e6

See more details on using hashes here.

File details

Details for the file canton-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for canton-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 3f52e21458df5cc1fa9b8047c959267a062e435dc98abef514b8af7bdabebc35
MD5 812add3e67391f68bc91a1cea0e5f9a4
BLAKE2b-256 a01165f09402ad139b9c69a6c11e06c9adc66a4ed3958484191f301150c53a41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page