chenxijun1029 / deepfm_with_pytorch Goto Github PK
View Code? Open in Web Editor NEWA PyTorch implementation of DeepFM for CTR prediction problem.
A PyTorch implementation of DeepFM for CTR prediction problem.
Hello, Could you tell me why it is 20? What's the meaning of it?
In the part of DeepFM.Forward
"""
emb = self.fm_first_order_embeddings[20]
print(Xi.size())
for num in Xi[:, 20, :][0]:
if num > self.feature_sizes[20]:
print("index out")
"""
您好, 请问下原文中在 deep part中有使用 激活函数, 而这份代码中没用,是出于其他什么考虑吗?
in data/dataset.py
if self.train:
# index of continous features are zero
Xi_coutinous = np.zeros_like(dataI[:continous_features])
else:
# index of continous features are one
Xi_coutinous = np.ones_like(dataI[:continous_features])
Why are the indexes generated by the continuous variables of the training set and the test set zero and one respectively? And should index for each continuous variable be the same?
class ContinuousFeatureGenerator:
"""
Clip continuous features.
"""
def __init__(self, num_feature):
self.num_feature = num_feature
def build(self, datafile, continous_features):
df = pd.read_csv(datafile, sep="\t", header=True)
with open(datafile, 'r') as f:
for line in f:
features = line.rstrip('\n').split('\t')
for i in range(0, self.num_feature):
val = features[continous_features[i]]
if val != '':
val = int(val)
if val > continous_clip[i]:
val = continous_clip[i] # 这个val弄了半天,也没存储,赋值,所以处理了有啥用呀
def gen(self, idx, val):
if val == '':
return 0.0
val = float(val)
return val
一、
dataPreprocess.py代码,86行,num_train_sample = 10000,这里应该是1000000吧?
否则运行main.py报错IndexError: index 9999 is out of bounds for axis 0 with size 9999
二、
dataPreprocess.py代码的连续值处理的裁剪没有生效,(代码原因),也可以做个测试,修改continous_clip = [20, 600, 100, 50, 64000, 500, 100, 50, 500, 10, 10, 10, 50],比如为0,会发现生成出来的train.txt中的连续值不会是0,即裁剪未生效
In dataset.py
, line 29 and 33, you usepd.read_csv
to read from your data that generated from original data. However, you forget to add param header = -1
, because the new test.csv
and train.csv
actully don't have a header. And pandas
will use the first line of data as the header, which will cause an index error later.
The follows are what the code should be like.
data = pd.read_csv(os.path.join(root, 'train.txt'), header = -1)
data = pd.read_csv(os.path.join(root, 'test.txt'), header = -1)
observing the following error while running deep ctr on the gpu:
Traceback (most recent call last):
File "main.py", line 31, in
model.fit(loader_train, loader_val, optimizer, epochs=5, verbose=True)
File "/root/deepctr/DeepFM_with_PyTorch/model/DeepFM.py", line 153, in fit
total = model(xi, xv)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/root/deepctr/DeepFM_with_PyTorch/model/DeepFM.py", line 98, in forward
fm_first_order_emb_arr = [(torch.sum(emb(Xi[:, i, :]), 1).t() * Xv[:, i]).t() for i, emb in enumerate(self.fm_first_order_embeddings)]
File "/root/deepctr/DeepFM_with_PyTorch/model/DeepFM.py", line 98, in
fm_first_order_emb_arr = [(torch.sum(emb(Xi[:, i, :]), 1).t() * Xv[:, i]).t() for i, emb in enumerate(self.fm_first_order_embeddings)]
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/sparse.py", line 118, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "/usr/local/lib/python3.5/dist-packages/torch/nn/functional.py", line 1454, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: index out of range at /pytorch/aten/src/TH/generic/THTensorEvenMoreMath.cpp:191
the above are code at model/DeepFM.py
Hi, Is the code above same as origin paper DeepFM proposed order-2 pairwise feature interactions?
I didn't see any pairwise feature interaction result e.g. f*f shape matrix.
Is that a problem!??
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.