Skip to content

Commit

Permalink
update lstm
Browse files Browse the repository at this point in the history
  • Loading branch information
sunlanchang committed Jun 19, 2020
1 parent ca5bc04 commit c999f0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions LSTM_age_gender.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_train_val():

# 提取词向量文件
def get_embedding(feature_name, tokenizer):
path = f"word2vec/wordvectors_{feature_name}.kv"
path = f"word2vec_new/{feature_name}.kv"
wv = KeyedVectors.load(path, mmap='r')
feature_tokens = list(wv.vocab.keys())
embedding_dim = 128
Expand All @@ -94,13 +94,13 @@ def get_embedding(feature_name, tokenizer):

# 从序列文件提取array格式数据
def get_train(feature_name, vocab_size, len_feature):
f = open(f'word2vec/userid_{feature_name}s.txt')
f = open(f'word2vec_new/{feature_name}.txt')
tokenizer = Tokenizer(num_words=vocab_size)
tokenizer.fit_on_texts(f)
f.close()

feature_seq = []
with open(f'word2vec/userid_{feature_name}s.txt') as f:
with open(f'word2vec_new/{feature_name}.txt') as f:
for text in f:
feature_seq.append(text.strip())

Expand Down
4 changes: 2 additions & 2 deletions word2vec_creative_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from mail import mail
# %%
df_train = pd.read_csv(
'data/train_preliminary/clicklog_ad_user_train_eval_test.csv')
df_test = pd.read_csv('data/test/clicklog_ad_user_test.csv')
'data/click_log_ad.csv')
# df_test = pd.read_csv('data/test/clicklog_ad_user_test.csv')
columns = ['user_id', 'creative_id', 'time']
frame = [df_train[columns], df_test[columns]]
df_train_test = pd.concat(frame, ignore_index=True)
Expand Down
8 changes: 8 additions & 0 deletions word2vec_new/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# .gitignore sample
###################

# Ignore all files in this dir...
*

# ... except for this one.
!.gitignore

0 comments on commit c999f0c

Please sign in to comment.