Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use mmh3 instead of pyhash? #81

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions calvin_models/calvin_agent/datasets/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
)
import numpy as np
from omegaconf import DictConfig
import pyhash
import mmh3
import torch
from torch.utils.data import Dataset

hasher = pyhash.fnv1_32()
logger = logging.getLogger(__name__)


Expand All @@ -33,7 +32,7 @@ def get_validation_window_size(idx: int, min_window_size: int, max_window_size:
Window size computed with hash function.
"""
window_range = max_window_size - min_window_size + 1
return min_window_size + hasher(str(idx)) % window_range
return min_window_size + mmh3.hash(str(idx)) % window_range


class BaseDataset(Dataset):
Expand Down
5 changes: 2 additions & 3 deletions calvin_models/calvin_agent/evaluation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
import numpy as np
from numpy import pi
from omegaconf import OmegaConf
import pyhash
import mmh3
import torch

hasher = pyhash.fnv1_32()
logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -232,7 +231,7 @@ def get_env_state_for_initial_condition(initial_condition):
np.array([2.29995412e-01, -1.19995140e-01, 4.59990010e-01]),
]
# we want to have a "deterministic" random seed for each initial condition
seed = hasher(str(initial_condition.values()))
seed = mmh3.hash(str(initial_condition.values()))
with temp_seed(seed):
np.random.shuffle(block_table)

Expand Down
2 changes: 1 addition & 1 deletion calvin_models/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ matplotlib
opencv-python
omegaconf
plotly
pyhash
mmh3
pytorch-lightning==1.8.6
lightning_lite
torch==1.13.1
Expand Down