You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtensorflowastffromlbnimportLBN# initialize the LBN, set 10 combinations and pairwise boostinglbn=LBN(10, boost_mode=LBN.PAIRS)
# create a feature tensor based on input four-vectorsfeatures=lbn(four_vectors)
# use the features as input for a subsequent, application-specific network
...
Or with TensorFlow 2 and Keras:
importtensorflowastffromlbnimportLBN, LBNLayer# start a sequential modelmodel=tf.keras.models.Sequential()
# add the LBN layerinput_shape= (6, 4)
model.add(LBNLayer(input_shape, 10, boost_mode=LBN.PAIRS))
# add a dense layermodel.add(tf.keras.layers.Dense(1024))
# continue builing and training the model
...
For more examples on how to set up the LBN with TensorFlow (eager mode and autograph / tf.function ) and Keras, see this gist.
NumPy and TensorFlow are the only dependencies. Both TensorFlow v1 and v2 are supported.
Testing
Tests should be run for Python 2 and 3 and for TensorFlow 1 and 2. The following commands assume you are in the root directory of the LBN respository:
python -m unittest test# or via dockerfortagin 1.15.2 1.15.2-py3 2.1.0 2.2.0;do
docker run --rm -v `pwd`:/root/lbn -w /root/lbn tensorflow/tensorflow:$tag python -m unittest testdone
Contributing
If you like to contribute, we are happy to receive pull requests. Just make sure to add new test cases and run the tests. Also, please use a coding style that is compatible with our .flake8 config.