Skip to content

Commit

Permalink
correct gamma tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
vzantedeschi committed Mar 10, 2017
1 parent c77283a commit 37a8050
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/l3svms.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def learning(train_x,train_y,test_x,test_y,printf=print,CLUS=1,PCA_BOOL=False,LI
t5 = time.time()
printf("training time:",t5-t4,"s")

te_x = parallelized_projection(-1,test_x,landmarks,clusters=test_clusters,unit_vectors=u,linear=LIN)
# te_x = project(test_x,landmarks,clusters=test_clusters,unit_vectors=u,linear=LIN)
te_x = parallelized_projection(-1,test_x,landmarks,clusters=test_clusters,unit_vectors=u,linear=LIN,gamma=best_G)
# te_x = project(test_x,landmarks,clusters=test_clusters,unit_vectors=u,linear=LIN,gamma=best_G)
p_label,p_acc,p_val = predict(test_y, te_x, model)

t6 = time.time()
Expand Down
6 changes: 3 additions & 3 deletions src/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from src.utils import array_to_dict

def project(x,landmarks,clusters=None,unit_vectors=None,linear=True):
def project(x,landmarks,clusters=None,unit_vectors=None,linear=True,gamma=1):

# project on landmark space
if unit_vectors is not None:
Expand All @@ -22,7 +22,7 @@ def project(x,landmarks,clusters=None,unit_vectors=None,linear=True):
if linear:
projection = x.dot(landmarks.transpose())
else:
projection = pairwise.rbf_kernel(x,landmarks)
projection = pairwise.rbf_kernel(x,landmarks,gamma=gamma)

if clusters is not None:
assert len(clusters) == x.shape[0]
Expand All @@ -42,7 +42,7 @@ def project_with_id(indexes,x,landmarks,clusters=None,unit_vectors=None,linear=T
if linear:
projection = a.dot(landmarks.transpose())
else:
projection = pairwise.rbf_kernel(a,landmarks)
projection = pairwise.rbf_kernel(a,landmarks,gamma=gamma)

if clusters is not None:
return array_to_dict(projection,clusters=clusters[indexes],land=landmarks.shape[0])
Expand Down

0 comments on commit 37a8050

Please sign in to comment.