Python wrapper for damo, a set of fast and robust hash functions.
Project description
Damo-Embedding
Quick Install
pip install damo-embedding
Example
DeepFM
import torch
import torch.nn as nn
from damo_embedding import Embedding
class DeepFM(torch.nn.Module):
def __init__(
self,
emb_size: int,
fea_size: int,
hid_dims=[256, 128],
num_classes=1,
dropout=[0.2, 0.2],
**kwargs,
):
super(DeepFM, self).__init__()
self.emb_size = emb_size
self.fea_size = fea_size
initializer = {
"name": "truncate_normal",
"mean": float(kwargs.get("mean", 0.0)),
"stddev": float(kwargs.get("stddev", 0.0001)),
}
optimizer = {
"name": "adam",
"gamma": float(kwargs.get("gamma", 0.001)),
"beta1": float(kwargs.get("beta1", 0.9)),
"beta2": float(kwargs.get("beta2", 0.999)),
"lambda": float(kwargs.get("lambda", 0.0)),
"epsilon": float(kwargs.get("epsilon", 1e-8)),
}
self.w = Embedding(
1,
initializer=initializer,
optimizer=optimizer,
)
self.v = Embedding(
self.emb_size,
initializer=initializer,
optimizer=optimizer,
)
self.w0 = torch.zeros(1, dtype=torch.float32, requires_grad=True)
self.dims = [fea_size * emb_size] + hid_dims
self.layers = nn.ModuleList()
for i in range(1, len(self.dims)):
self.layers.append(nn.Linear(self.dims[i - 1], self.dims[i]))
self.layers.append(nn.BatchNorm1d(self.dims[i]))
self.layers.append(nn.BatchNorm1d(self.dims[i]))
self.layers.append(nn.ReLU())
self.layers.append(nn.Dropout(dropout[i - 1]))
self.layers.append(nn.Linear(self.dims[-1], num_classes))
self.sigmoid = nn.Sigmoid()
def forward(self, input: torch.Tensor) -> torch.Tensor:
"""forward
Args:
input (torch.Tensor): input tensor
Returns:
tensor.Tensor: deepfm forward values
"""
assert input.shape[1] == self.fea_size
w = self.w.forward(input)
v = self.v.forward(input)
square_of_sum = torch.pow(torch.sum(v, dim=1), 2)
sum_of_square = torch.sum(v * v, dim=1)
fm_out = (
torch.sum((square_of_sum - sum_of_square)
* 0.5, dim=1, keepdim=True)
+ torch.sum(w, dim=1)
+ self.w0
)
dnn_out = torch.flatten(v, 1)
for layer in self.layers:
dnn_out = layer(dnn_out)
out = fm_out + dnn_out
out = self.sigmoid(out)
return out
Save Model
from damo_embedding import save_model
model = DeepFM(8, 39)
save_model(model, "./", training=False)
Document
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file damo-embedding-1.1.12.tar.gz.
File metadata
- Download URL: damo-embedding-1.1.12.tar.gz
- Upload date:
- Size: 232.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f914073113365094f621ce596f68005f5e909e17523f6eb1333ba22a382a3bff
|
|
| MD5 |
981e4ada324eb3ac0cd43f8c93fe3b3b
|
|
| BLAKE2b-256 |
727147782cde7883e3eab838f0ad7dae70cb2428f8b83469c158cf36e54be9cd
|
File details
Details for the file damo_embedding-1.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f13ea959ddf2f7954d1cba65ec8498387c5d63440ce0306b58b813bb61a30b66
|
|
| MD5 |
f26e8fbc6dc39ba79b289417d73122d3
|
|
| BLAKE2b-256 |
9ceff7cf26d7cae3ed8116ed936b0cac24b199c30afcb3e22b34be5a8c61aa0f
|
File details
Details for the file damo_embedding-1.1.12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaf66631c1beefd17a7b95591fff6697c5adf96c880dd5b0860b7715231295a0
|
|
| MD5 |
33eda4fea07cf47cd7f6d7443ddb8b0b
|
|
| BLAKE2b-256 |
6b89fae62be1e953015b17cc5ffcbfb675a158aa1e347163ac40a8aeb8aad238
|
File details
Details for the file damo_embedding-1.1.12-cp312-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb7e63fcae1c61e0339a74c729c98b96226bfb9926289d3b4113a01c58df7299
|
|
| MD5 |
d008ff8b9500a674f5f42a345915f38b
|
|
| BLAKE2b-256 |
b686311b6930e50f32bb56beb0071f6166f3e1afd192960dbbd464bc8fa2ae0b
|
File details
Details for the file damo_embedding-1.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4225560230bffdfe7580ebe9ffe30df61a6f16f389d10b8bd4e4de43650d1754
|
|
| MD5 |
a050defcd6b9ec6a44a7729926ba95d8
|
|
| BLAKE2b-256 |
32e5eb1aa0fc030e6231b024a9bc10ddf8c7f4a3fce287eb656435bc96569013
|
File details
Details for the file damo_embedding-1.1.12-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41502faab14bfdbae7be2cba4844cd9583255e7833de6f2647aacc1b7298c64e
|
|
| MD5 |
6f563d4c076798446526773b73fe5e6b
|
|
| BLAKE2b-256 |
79763658155c7981ba72cfe976f3abcccefa5c8f2bdf7aa17db773dce6cbb9c5
|
File details
Details for the file damo_embedding-1.1.12-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2727e6c59cd07ae053a5ef9a2dacda73c1329c809950a6b15c226223df06950
|
|
| MD5 |
a51b5fc0378d46e25719e82797500328
|
|
| BLAKE2b-256 |
68e1009d7e26cdd602fb8550165df4519a83bf7a8bed3f49552a36ad659fdf4f
|
File details
Details for the file damo_embedding-1.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b9b96ebad1fe7617e45448257b1d2bf43956b41560af427c97a3c722f17dfbf
|
|
| MD5 |
787d8bff7f865d81ffb6d42a31d518e0
|
|
| BLAKE2b-256 |
69f60e82a38f2dde1488e6635493637d3a45f4b9f1b94f7029eba21a9ba1ea6a
|
File details
Details for the file damo_embedding-1.1.12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
809ccb4130ffb0be18bbf6208e020dca9273d42cfdd0279d81bdc635f66d15fe
|
|
| MD5 |
a14ccc102c3ff8bde8b3d3074fb616a9
|
|
| BLAKE2b-256 |
411566fad0cfc8f93954cf116e74c7e062dcf4a84c10486feb174655ccf347c4
|
File details
Details for the file damo_embedding-1.1.12-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b115d35beeeddefe665f320560e5a5611be384a6a0da9eed7c3982038c01f312
|
|
| MD5 |
5f7ba942bb4cb9a99c692715f23fe9d8
|
|
| BLAKE2b-256 |
4dea32e3260b070a2d3f67f133f4e6c889065bb733973052ba5801c9dea5e8aa
|
File details
Details for the file damo_embedding-1.1.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c1bc992a9a3db13d19e5ade16908c2bd2bcae6c647fa35b38d94cc27e6e6e71
|
|
| MD5 |
9acb151ee1d3d84aeac5973241b6b92e
|
|
| BLAKE2b-256 |
2f3b9cf5a1a145a943eefc74e6d4e8c785e5b4379ffd137afea9c20b63a0bab6
|
File details
Details for the file damo_embedding-1.1.12-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33f0e1087cfa18917eec2a64d70d8932dd00af51ff5979badbc6d6adb3144fe6
|
|
| MD5 |
13143ea35de347d259b7dc902db110f1
|
|
| BLAKE2b-256 |
63fc5e2d9616145c6c588b7843502e2181272b51d38dfbf93a8f41bd68a62249
|
File details
Details for the file damo_embedding-1.1.12-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a50d8b006fbaeb37a7abb77102d3756f896cfa1e4a371f7dd442dd3d32d5b0a
|
|
| MD5 |
151c18da641346943af1768396092c36
|
|
| BLAKE2b-256 |
cf4a1fe9565ed5be07a3f666b65bf973316673cd5072d313aeab3841135f81df
|
File details
Details for the file damo_embedding-1.1.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a7933e4782d169dc877c5166d553ffa861b3ecba627a393d9aab66a78a2328d
|
|
| MD5 |
48868aba913b8573d0da4b6fc2aba32f
|
|
| BLAKE2b-256 |
d5060c04c44620ae422cf6da4d23a8c7d2a75303e20c7fa596f755488d245f92
|
File details
Details for the file damo_embedding-1.1.12-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
036c8bb3341726e679546885f132a07ac39d8fd4bc5762e31ee988972e48d424
|
|
| MD5 |
7dd828eb596d8a7696f7bf26863a4527
|
|
| BLAKE2b-256 |
2234e5cdd705103d4eceb168e19a09f4690f2b68d889b028dbe6c3420685d02d
|
File details
Details for the file damo_embedding-1.1.12-cp38-cp38-macosx_10_9_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a854913387e08831eadeba6fc796c0efd2cf9e123f07da7cc87957d14fc1773
|
|
| MD5 |
f3ae65d81b1cfa6aae555d2ce7c01594
|
|
| BLAKE2b-256 |
271d45265d879424fbfd7eee404dc11646d1df552f8774305547685b1d03dfa9
|
File details
Details for the file damo_embedding-1.1.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61c43ea193757bdbf125e9ab8ffe68b3a7c26fd39c813784ba999c908940789e
|
|
| MD5 |
460feb364b08503756930620968196c5
|
|
| BLAKE2b-256 |
b33e162b615e0d815e8fedb26fa05f4cf957ddd304217b03a54e603a358f4222
|
File details
Details for the file damo_embedding-1.1.12-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a394c6928f7780ef68044c5fb12a37e1b2a8afb46315d06d192ff0826e3b103a
|
|
| MD5 |
dab0d3aadbc2a4dceeda8618a70d3100
|
|
| BLAKE2b-256 |
74bbf8b3276dedd5abd6a06dffefd5ff53b6649f7b24d97ed813c1715710993e
|
File details
Details for the file damo_embedding-1.1.12-cp37-cp37m-macosx_10_9_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19b419e916169f613f422a40e529d586803650d9b79a9b35a18d7970c00d0e9b
|
|
| MD5 |
12068bdabfe6ad22ec78efe67f7e631d
|
|
| BLAKE2b-256 |
c1c7fd6e5d563dd76f57e090d62641222d5230024e22f0b21b38f1a9462d39a3
|
File details
Details for the file damo_embedding-1.1.12-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.8 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
027b187d5e7fab22f183dfb326fc15b2a1290d099a728f0818029e6e979c5ac3
|
|
| MD5 |
de480d71e91a95edad3f08b1369aa4fd
|
|
| BLAKE2b-256 |
e5d610f6ab5efe4d8096bc11876d09c322b70808a3262adfb7dfdd04e06a40ac
|
File details
Details for the file damo_embedding-1.1.12-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02cf76e538c273e86cc60964d2f342169740fa708fb8552ad6b9deadbbc5ff8a
|
|
| MD5 |
d02a3abeb19d841e7ffe2183d044476a
|
|
| BLAKE2b-256 |
230b4f9de1fc774420284450f51679a8c25e337a51411ffa87aadca5f45e1be2
|
File details
Details for the file damo_embedding-1.1.12-cp36-cp36m-macosx_10_9_x86_64.whl.
File metadata
- Download URL: damo_embedding-1.1.12-cp36-cp36m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.6m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ca7d864bbcc613f788fc49d2bc697e96da62d1dac915179b1edf6fd925d07ea
|
|
| MD5 |
fe6d1b95f86dca4be857622af980c51a
|
|
| BLAKE2b-256 |
d1afac0ec70a68334defee34719b1acd19f2ad5deca6fa8f71bbe266afafe974
|