Skip to content

Instantly share code, notes, and snippets.

@varrek
Last active January 15, 2022 20:13
Show Gist options
  • Select an option

  • Save varrek/028cb1edf55fd36b2795ce7b79b19d25 to your computer and use it in GitHub Desktop.

Select an option

Save varrek/028cb1edf55fd36b2795ce7b79b19d25 to your computer and use it in GitHub Desktop.
import tensorflow_hub as hub
import tensorflow_text
embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual/3")
df_test = pd.read_csv(os.path.join(INPUT_DIR, "test.csv"), header=0)
categories = df_test.targetcat.unique()
df = pd.DataFrame({'cat_name':categories})
df['cat_embeding'] = embed(df['cat_name'])
df['cat_embeding'] = df['cat_embeding'].apply(lambda x: np.asarray(x))
df_test['embed'] = embed(df_test['description'])
df_test['embed'] = df_test['embed'].apply(lambda x: np.asarray(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment