tensorflow-models - TensorFlow machine learning models.
A collection of helpful models for streamlining the creation of machine learning models Developed in the CAMEL lab at Clarkson University for anomaly detection.
Currently, just contains the NeuralNet model. Planning to add more models.
A model for creating a fully connected feed forward neural net given a list of layer sizes and activation functions.
We can create a model by passing a list of layer sizes and a list of activation functions.
model = models.NeuralNet.NeuralNet(
[num_input, 100, num_output],
[tf.nn.relu, tf.nn.sigmoid]
)
We can build the computation graph using the function create_network
. An example is provided below
X = tf.placeholder('float', [None, num_inputs])
keep_prob = tf.placeholder('float')
prediction = model.create_network(X, keep_prob)
The L2 loss can be added to the objective function by calling get_l2_loss
.
cost += 0.01 * model.get_l2_loss()
Using reset_weights
returns a tensor operation to reset the weights using sess.run
with tf.Session() as sess:
sess.run(model.reset_weights())