Skip to content

Instantly share code, notes, and snippets.

@vfdev-5
Last active June 30, 2016 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfdev-5/e625ea58869cf83609cc5b0f8c7fe329 to your computer and use it in GitHub Desktop.
Save vfdev-5/e625ea58869cf83609cc5b0f8c7fe329 to your computer and use it in GitHub Desktop.
Simple logistic regression classifier using CAFFE
#!/bin/python2
# Python
# Numpy
import numpy as np
# Matplotlib
import matplotlib.pyplot as plt
if __name__ == "__main__":
print "Generate two sets of 2D points"
mean_1 = (13.4, 5.4)
cov_1 = [[2.4, 1.56],[-0.87, 0.61]]
mean_2 = (8.4, -2.4)
cov_2 = [[12.4, 5.34],[-2.17, 5.1]]
first_set = np.random.multivariate_normal(mean_1, cov_1, 100)
second_set = np.random.multivariate_normal(mean_2, cov_2, 100)
#print first_set.shape
plt.scatter(first_set[:,0], first_set[:,1], c='red')
plt.scatter(second_set[:,0], second_set[:,1], c='blue')
plt.show()
################################
# simple logistic regression classifier
################################
name: "simple logistic regression classifier"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
}
layer {
name: "fc"
type: "InnerProduct"
bottom: "data"
top: "fc"
inner_product_param {
num_output: 2
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "fc"
bottom: "label"
top: "loss"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment