Skip to content

Commit

Permalink
100 is not a hardcoded dimension any more
Browse files Browse the repository at this point in the history
  • Loading branch information
spyrchat committed Dec 8, 2023
1 parent f9c280c commit e35ecba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions HDC_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def train_HDC_RFF(n_class, N_train, Y_train_init, HDC_cont_train, gamma, D_b):
alpha = np.linalg.solve(Beta,L) #alpha here is the whole v vector from the slides

# Get HDC prototype for class cla, still in floating point
final_HDC_centroid = np.zeros(100)
final_HDC_centroid_q = np.zeros(100)
final_HDC_centroid = np.zeros(np.shape(HDC_cont_train[0]))
final_HDC_centroid_q = np.zeros(np.shape(HDC_cont_train[0]))

for i in range(N_train):
final_HDC_centroid = final_HDC_centroid + Y_train[i]*alpha[i]*HDC_cont_train[i] #this is mu(vector) from the slides
Expand Down Expand Up @@ -160,7 +160,7 @@ def evaluate_F_of_x(Nbr_of_trials, HDC_cont_all, LABELS, beta_, bias_, gamma, al
HDC_cont_train_cpy = HDC_cont_train_ * 1
# Apply cyclic accumulation with biases and accumulation speed beta_
cyclic_accumulation_train = HDC_cont_train_cpy % (2 ** B_cnt)
HDC_cont_train_cyclic = np.zeros((cyclic_accumulation_train.shape[0],100))
HDC_cont_train_cyclic = np.zeros((cyclic_accumulation_train.shape[0],HDC_cont_all.shape[1]))

for row in range(cyclic_accumulation_train.shape[0]):
cyclic_accumulation_train_vector = np.array(cyclic_accumulation_train[row])
Expand Down Expand Up @@ -194,7 +194,7 @@ def evaluate_F_of_x(Nbr_of_trials, HDC_cont_all, LABELS, beta_, bias_, gamma, al
# Apply cyclic accumulation with biases and accumulation speed beta_

cyclic_accumulation_test = HDC_cont_test_cpy % (2 ** B_cnt)
HDC_cont_test_cyclic = np.zeros((cyclic_accumulation_test.shape[0],100))
HDC_cont_test_cyclic = np.zeros((cyclic_accumulation_test.shape[0],HDC_cont_all.shape[1]))
for row in range(cyclic_accumulation_test.shape[0]):
cyclic_accumulation_test_vector = np.array(cyclic_accumulation_test[row])

Expand Down
10 changes: 5 additions & 5 deletions playground_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ def test_XOR(in1,in2,desired,dim):

dataset_path = 'WISCONSIN/data.csv'
##################################
imgsize_vector = 30 #Each input vector has 30 features
imgsize_vector = 100 #Each input vector has 30 features
n_class = 2
D_b = 4 #We target 4-bit HDC prototypes
D_b = 8 #We target 4-bit HDC prototypes
B_cnt = 8
maxval = 256 #The input features will be mapped from 0 to 255 (8-bit)
D_HDC = 100 #HDC hypervector dimension
D_HDC = 300 #HDC hypervector dimension
portion = 0.6 #We choose 60%-40% split between train and test sets
Nbr_of_trials = 1 #Test accuracy averaged over Nbr_of_trials runs
N_tradeof_points = 40 #Number of tradeoff points - use 100
Nbr_of_trials = 8 #Test accuracy averaged over Nbr_of_trials runs
N_tradeof_points = 100 #Number of tradeoff points - use 100
N_fine = int(N_tradeof_points*0.4) #Number of tradeoff points in the "fine-grain" region - use 30
#Initialize the sparsity-accuracy hyperparameter search
lambda_fine = np.linspace(-0.2, 0.2, N_tradeof_points-N_fine)
Expand Down

0 comments on commit e35ecba

Please sign in to comment.