Last active
June 30, 2016 17:40
-
-
Save vfdev-5/e625ea58869cf83609cc5b0f8c7fe329 to your computer and use it in GitHub Desktop.
Simple logistic regression classifier using CAFFE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################ | |
# 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