felipekitamura commited on
Commit
83fbef1
·
verified ·
1 Parent(s): dfa856e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -33,7 +33,7 @@ def plot_reduced_data(reduced_data, labels, title):
33
  arrowprops=dict(arrowstyle="->", color='green', lw=3))
34
 
35
  # Data for the arrow 2
36
- end_point = (reduced_data[2, 0] - (reduced_data[0, 0] - reduced_data[1, 0]), reduced_data[2, 1] - (reduced_data[0, 1] - reduced_data[1, 1])) # Starting point of the arrow
37
  start_point = (reduced_data[2, 0], reduced_data[2, 1]) # Ending point of the arrow
38
 
39
  # Adding an arrow 2
@@ -64,11 +64,13 @@ sp = gr.Image()
64
 
65
 
66
  def inference(word1, word2, word3):
67
- output = model.similar_by_vector(model[word3] + model[word2] - model[word1])
 
68
  print(output)
69
  word_list = [word1, word2, word3]
70
  word_list.extend([x for x,y in [item for item in output[:4]]])
71
  words = {key: model[key] for key in word_list}
 
72
  data = np.concatenate([x[np.newaxis, :] for x in words.values()], axis=0)
73
  print(data.shape)
74
  labels = words.keys()
 
33
  arrowprops=dict(arrowstyle="->", color='green', lw=3))
34
 
35
  # Data for the arrow 2
36
+ end_point = ((reduced_data[-1, 0] , (reduced_data[-1, 1])) # Starting point of the arrow
37
  start_point = (reduced_data[2, 0], reduced_data[2, 1]) # Ending point of the arrow
38
 
39
  # Adding an arrow 2
 
64
 
65
 
66
  def inference(word1, word2, word3):
67
+ transform = model[word3] + model[word2] - model[word1]
68
+ output = model.similar_by_vector(transform)
69
  print(output)
70
  word_list = [word1, word2, word3]
71
  word_list.extend([x for x,y in [item for item in output[:4]]])
72
  words = {key: model[key] for key in word_list}
73
+ words["Equivalent"] = transform
74
  data = np.concatenate([x[np.newaxis, :] for x in words.values()], axis=0)
75
  print(data.shape)
76
  labels = words.keys()