Skip to content

Instantly share code, notes, and snippets.

@sanuj
Created June 20, 2016 08:45
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 sanuj/e24d003b5af990fee1b772129ace75fa to your computer and use it in GitHub Desktop.
Save sanuj/e24d003b5af990fee1b772129ace75fa to your computer and use it in GitHub Desktop.
Demo code for usage of Tags and new parameter framework in Shogun
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