antipasti-tf
antipasti-tf copied to clipboard
GraphModels with NetworkX
In addition to the LayerTrainyard
for building networks whos graphs are to be specified as a Hasse diagram, NetworkX can be used to defined models in a much more flexible, yet non-functional manner. NetworkX can be used to toposort the model for feeding forward or for shape inference. Coupled with a flexible UI, this could be a viable alternative to the functional way of building networks. Here's how I envision the API:
# Initialize graph (which can also be done by passing a config to the GraphModel constructor)
network = GraphModel()
network.add_layer(this_layer='conv1', layer='convolution',
maps_in=1, maps_out=10, kernel_size=[3, 3])
network.add_layer(previous_layer='conv1', this_layer='pool1', layer='pool',
window=[3, 3], stride=[2, 2])
# Add a layer between conv1 and pool1
network.add_layer(previous_layer='conv1', next_layer='pool1', this_layer='conv1.5', layer='convolution',
maps_in=10, maps_out=20, kernel_size=[3, 3])
# Build model
network.feedforward()
# Fit
# ...
In principle, it should be possible to wrap the add_layer method (e.g. as a partial function add_layer_after
) to have a functional API.
What do you think, @lukas-schott & @DerThorsten ?