Created
June 20, 2016 08:45
-
-
Save sanuj/e24d003b5af990fee1b772129ace75fa to your computer and use it in GitHub Desktop.
Demo code for usage of Tags and new parameter framework in Shogun
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
import modshogun as sg | |
ck = sg.CombinedKernel() | |
ck.setInt("num_kernels", 3) | |
gk = sg.GaussianKernel(10, 5) | |
gk_tag = sg.TagKernel("gaussian") | |
print gk == ck.set(gk_tag, gk) # returns gk | |
if gk == ck.getKernel("gaussian") and gk == ck.get(gk_tag): | |
print "Fetched gaussian kernel with width = 5" | |
print ck.has("blah") | |
print ck.has(gk_tag) | |
print ck.has("gaussian") | |
print ck.hasKernel("gaussian") | |
print ck.hasFeatures("gaussian") | |
another_gk = sg.GaussianKernel(10, 2) | |
if gk == ck.setKernel("gaussian", another_gk): | |
# Returns current object when updated with same name | |
print "New kernel succesfully updated with width = 2." | |
lk = sg.LinearKernel() | |
pk = sg.PolyKernel(10,3) | |
ck.setKernel("linear", lk) | |
ck.setKernel("poly", pk) | |
print "CombinedKernel object has following parameters:" | |
for param in ck.all_parameters(): | |
print param |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment