Comments (3)
Dear DaLao: what's the function of "self.offsets" ?
self.offsets = np.array((0, *np.cumsum(field_dims)[:-1]), dtype=np.long) def forward(self, x): x = x + x.new_tensor(self.offsets).unsqueeze(0)
# e.g. field_dims = [2, 3, 4, 5], offsets = [0, 2, 5, 9]
# 索引的偏移量
# 因为所有特征共用一个 Embedding表
# 所以,实际表中 0~1行 对应 特征 X0, 即 field_dims[0]
# 2~4行 对应 特征 X1, 即 field_dims[1]
# 5~8行 对应 特征 X2, 即 field_dims[2]
# 9~14行 对应 特征 X3, 即 field_dims[3]
# 但实际特征取值 forward(self, x) 的 x大小 只在自身词表内取值
# 比如:X1取值0,对应Embedding内行数就是 offsets[X1] + X1 = 2 + 0 = 2
from pytorch-fm.
feature index offset of each field
from pytorch-fm.
细节上说的有一点小小的错误
- 若field_dim = [5,10,5], np.cumsum(field_dims)[:-1]=[5,15], 所以源码中 补了一个零 np.array((0, *np.cumsum(field_dims)[:-1])
from pytorch-fm.
Related Issues (20)
- F.dropout的问题 HOT 1
- FactorizationMachine implementation and paper are different HOT 2
- PaddingIdx HOT 1
- One mistake in class MultiLayerPerceptron(torch.nn.Module) in layers.py HOT 1
- why don't you do the pre-trianing in FNN model?
- ModuleNotFoundError: No module named 'torchfm.model.hofm' HOT 3
- autoint实现和论文有出入
- Real-valued features not supported?
- args = parser.parse_args() SystemExit: 2
- tensor for argument #1 HOT 1
- Why FM uses embedding? HOT 1
- one question about data process HOT 1
- Trying to run fnfm on avazu dataset
- network structure difference with deepFM paper
- why the fm model didn't consider the data value? HOT 1
- rank hyper parameter
- Cannot run example on my mac
- But in layers.cpp
- The new link of Criteo_dataset
- np.int and np.long deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch-fm.