Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ad8d2c1
req
NoaVelner Aug 25, 2024
6a1e98f
updated requirements.txt
ItamarBaer Aug 25, 2024
0c43723
codemaster_wn_lin.py
NoaVelner Aug 26, 2024
41dc12d
Merge remote-tracking branch 'origin/master'
NoaVelner Aug 26, 2024
e2edb68
codemaster_wn_lin.py
NoaVelner Aug 26, 2024
fa4b106
codemaster_wn_lin.py
NoaVelner Aug 26, 2024
66eba25
closet data set + preprocess
NoaVelner Aug 26, 2024
8a14745
closet data set + preprocess
NoaVelner Aug 26, 2024
37220c3
closet data set + preprocess
NoaVelner Aug 26, 2024
287e9d4
closet data set + preprocess
NoaVelner Aug 26, 2024
a01c5c8
more datasets
NoaVelner Aug 26, 2024
9b183f4
annealing agent v1
ItamarBaer Aug 26, 2024
bee2e46
Merge remote-tracking branch 'origin/codemaster' into codemaster
ItamarBaer Aug 26, 2024
98db9ec
annealing agent v1
ItamarBaer Aug 26, 2024
e347f99
guesser_w2vglove.py now uses glove only.
TamirP99 Aug 26, 2024
97426a0
Merge remote-tracking branch 'origin/codemaster' into codemaster
TamirP99 Aug 26, 2024
ce2b1ac
guesser_w2vglove.py now uses glove only.
TamirP99 Aug 26, 2024
b37bb35
shouldn't've changed this file
TamirP99 Aug 26, 2024
b4d6a44
committee_guesser.py for multi-Agent (only shell, without any algorithm)
NoaVelner Aug 26, 2024
e0b2150
annealing agent v2, which also find the nums in the annealing process.
ItamarBaer Aug 26, 2024
9eec37d
Merge remote-tracking branch 'origin/codemaster' into codemaster
ItamarBaer Aug 26, 2024
a86cb50
annealing agent v2, which also find the nums in the annealing process.
ItamarBaer Aug 26, 2024
f5ea11d
Added a new arg tag --num_games
ItamarBaer Aug 27, 2024
56b9032
Added a new arg tag --num_games
ItamarBaer Aug 27, 2024
367d432
Added a new arg tag --num_games
ItamarBaer Aug 27, 2024
dac4557
Added a new arg tag --num_games
ItamarBaer Aug 27, 2024
546046d
Added a new arg tag --num_games
ItamarBaer Aug 27, 2024
1073e95
random dialect guess matric
NoaVelner Aug 28, 2024
9fd8b18
added percentage utility
TamirP99 Aug 28, 2024
fba4360
correct matrix in random dialect
NoaVelner Aug 28, 2024
0d0d20a
Merge remote-tracking branch 'origin/codemaster' into codemaster
NoaVelner Aug 28, 2024
389c95b
correct matrix in random dialect
NoaVelner Aug 28, 2024
304f1e3
worked on percentage utility
TamirP99 Aug 29, 2024
a2ed28e
two player format
NoaVelner Aug 31, 2024
484e1cd
two player format
NoaVelner Aug 31, 2024
ea162c7
add lousy_guesser.py to have a naive baseline
NoaVelner Aug 31, 2024
d20103d
add lousy_guesser.py to have a naive baseline
NoaVelner Sep 1, 2024
8868a28
update game
NoaVelner Sep 1, 2024
a25c3c3
update game
NoaVelner Sep 1, 2024
10bc0cc
annealing agent:
ItamarBaer Sep 1, 2024
ad5a35b
Merge remote-tracking branch 'origin/codemaster' into codemaster
ItamarBaer Sep 1, 2024
68f267d
filtered to have no "stop" words.
ItamarBaer Sep 1, 2024
67bdd0b
update annealing_v4
NoaVelner Sep 1, 2024
ce2b568
Merge remote-tracking branch 'origin/codemaster' into codemaster
NoaVelner Sep 1, 2024
22c1f72
update annealing_v4
NoaVelner Sep 1, 2024
d2fbee3
all players are added via flag. some bug fixes
TamirP99 Sep 1, 2024
b3a3b83
game
NoaVelner Sep 1, 2024
12a9f1d
updated some codemasters to adhear the new game format. added the lea…
TamirP99 Sep 2, 2024
171f83d
plots and so
NoaVelner Sep 2, 2024
6b4ffa4
Merge remote-tracking branch 'origin/codemaster' into codemaster
NoaVelner Sep 2, 2024
9819f92
plots and so
NoaVelner Sep 2, 2024
d09f1d4
results of gloveVsgoogle
ItamarBaer Sep 3, 2024
f16df97
committees
NoaVelner Sep 4, 2024
d86e9d7
Merge remote-tracking branch 'origin/codemaster' into codemaster
NoaVelner Sep 4, 2024
263ffca
final: RD+sealed bid
NoaVelner Sep 5, 2024
5ec95e1
final: normalized+sealed bid
NoaVelner Sep 5, 2024
ba8ed21
final multi agents
NoaVelner Sep 7, 2024
98b7cb6
final multi agents
NoaVelner Sep 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions codenames/big_glove_to_w2v_learning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import tensorflow as tf
from tensorflow.keras import layers, models
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split

from codenames.game import Game

# Custom loss function using cosine distance
def cosine_distance_loss(y_true, y_pred):
# Calculate the cosine similarity and convert it to a distance
y_true = tf.math.l2_normalize(y_true, axis=-1)
y_pred = tf.math.l2_normalize(y_pred, axis=-1)
return 1 - tf.reduce_sum(y_true * y_pred, axis=-1)

def learn_vector_relationship(dict1, dict2, key_list, epochs=1024, batch_size=32, validation_split=0.2):
# Extract input (X) and output (Y) data based on the key list
X = np.array([dict1[key.lower()] for key in key_list])
Y = np.array([dict2[key.lower()] for key in key_list])

# Split the data into training and validation sets
X_train, X_val, Y_train, Y_val = train_test_split(X, Y, test_size=validation_split)

# Define a simple feedforward neural network
model = models.Sequential()
model.add(layers.Input(shape=(X.shape[1],))) # Input layer with number of units matching X's dimensionality
model.add(layers.Dense(300, activation='relu')) # Hidden layer with 128 units
model.add(layers.Dense(Y.shape[1])) # Output layer with number of units matching Y's dimensionality

# Compile the model
model.compile(optimizer='adam', loss=cosine_distance_loss)

# Train the model with validation
history = model.fit(X_train, Y_train, validation_data=(X_val, Y_val),
epochs=epochs, batch_size=batch_size)

# Plot the training and validation loss over epochs
plt.plot(history.history['loss'], label='Training Loss')
plt.plot(history.history['val_loss'], label='Validation Loss')
plt.title('Model Loss Over Epochs learning w2v from glove 300')
plt.xlabel('Epoch')
plt.ylabel('Loss (MSE)')
plt.legend()
plt.savefig("learning_loss_from_big_glove_to_w2v.png")
plt.show()

# Return the trained model
return model

if __name__ == "__main__":
# Example usage:
glove_vectors = Game.load_glove_vecs("players/glove.6B.300d.txt")
w2v_vectors = Game.load_w2v("players/GoogleNews-vectors-negative300.bin")
wordlist = []
with open('combine_words.txt') as infile:
for line in infile:
wordlist.append(line.rstrip().lower())
model = learn_vector_relationship(glove_vectors, w2v_vectors, wordlist)

# Prepare the input matrix for all words in the wordlist
input_vectors = np.array([glove_vectors[word.lower()] for word in wordlist])

# Predict all vectors at once
predicted_vectors = model.predict(input_vectors)

# Create the translated_vecs dictionary
translated_vecs = {word.lower(): predicted_vectors[i] for i, word in enumerate(wordlist)}
model.save('glove300_to_w2v_model.keras')

1 change: 1 addition & 0 deletions codenames/closest_combined_words_within_dataset.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions codenames/closest_words_within_dataset.json

Large diffs are not rendered by default.

Loading