Commit 018fdca8 authored by galenxing's avatar galenxing
Browse files

updates

parent 1fb5d41e
Loading
Loading
Loading
Loading
+10 −16
Original line number Diff line number Diff line
@@ -9,22 +9,22 @@ Tensorgraph is designed to be incredibly flexible for users attempting research
A TensorGraph model is pipeing around a series of layers.  Placing your Tensorflow code into a Tensorgraph means you don't have to worry about coding methods for fitting, training, and batching data, nor do you need to worry about writing picking and restoring functions. It also enables beautiful Tensorboard visualizations. 

### Layer
A Layer is a node in a graph.  A Layer class has a "name" and a __call__ function.  __call__ takes in a list of parent Layers, returns a tf.Tensor object, and sets the tf.Tensor object as self.out_tensor.  Below is an example layer which will reverse the order of the parent Tensor's 0th axis.
A Layer is a node in a graph.  A Layer class has a "name" and a create_tensor function.  create_tensor takes in a list of input Layers, returns a tf.Tensor object, and sets the tf.Tensor object as self.out_tensor.  Below is an example layer which will reverse the order of the parent Tensor's 0th axis.

``` python
class Reverse(Layer):
  def __call__(self, *parents):
    parent_out = parents[0].out_tensor
  def create_tensor(self, in_layers=None, set_tensors=True, **kwargs):
    parent_out = in_layers[0].out_tensor
    out_tensor = tf.reverse(parent_out, axis=0)
    if set_tensors:
    	self.out_tensor = out_tensor
    return out_tensor
```
You can combine these layers to form a Graph of computation by combining these layers on a tensorgraph.
``` python
tg = TensorGraph()
feature = Input(shape=(None, 5))
tg.add_layer(feature, parents=list())
reverse = Reverse() # From Above
tg.add_layer(Reverse(), parentes=[feature])
reverse = Reverse(in_layers=[feature]) # From Above
```
Now during computation, the reverse layer will reverse the feature layer.

@@ -35,18 +35,14 @@ Features are how we feed input data into our model. During training or predicti
tg = TensorGraph()
# Convention is to set batch size as 0th axis.
# None means any batch size is allowed.
feature = Input(shape=(None, 5))
tg.add_layer(feature)
tg.add_feature(feature)
feature = Feature(shape=(None, 5))
```

### Labels
Labels are the results we expect to get for each feature.  We feed Dataset.y into a label when "fit"ing a model.
```
tf = TensorGraph()
label = Input(shape=(None, 2)) # Example Binary Classification label
tf.add_layer(label)
tf.add_label(label)
label = Label(shape=(None, 2)) # Example Binary Classification label
```

### Loss
@@ -56,10 +52,8 @@ Loss is a scalar we wish to minimize for our network. When training, we will us
tg = TensorGraph()
# a is labels for a classification problem
# b is our guesses for the classification problem
smce = SoftMaxCrossEntropy()
tg.add_layer(smce, parents=[a, b])
redmean = ReduceMean()
tg.add_layer(redmean, parents=[smce])
smce = SoftMaxCrossEntropy(in_layers=[a,b])
redmean = ReduceMean(in_layers=[smce])
tg.set_loss(redmean)
```
Here in our classification problem, we are attempting to reduce the mean of a SoftMaxCrossEntropy.