Skip to content
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
1 change: 0 additions & 1 deletion rbms/bernoulli_gaussian/classes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import annotations
from botocore.vendored.six import u

import numpy as np
import torch
Expand Down
12 changes: 12 additions & 0 deletions rbms/custom_fn.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import h5py
import numpy as np
import torch
from torch import Tensor

Expand Down Expand Up @@ -47,3 +49,13 @@ def check_keys_dict(d: dict, names: list[str]):
raise ValueError(
f"""Dictionary params missing key '{k}'\n Provided keys : {d.keys()}\n Expected keys: {names}"""
)


def load_string(f: h5py.Dataset, k: str | bytes) -> str:
# Fix 1: Ensure key is a string
# key = k.decode("utf-8") if isinstance(k, bytes) else k
val = np.asarray(f[k])
# Fix 2: Ensure string values (like 'Reservoir') are strings, not bytes
if val.dtype.kind in ["S", "V", "O"]: # Bytes, Void, or Object (StringDType)
val = val.astype(str)
return str(val)
Loading