Update README.md
Browse files
README.md
CHANGED
|
@@ -8,14 +8,16 @@ If you want to use them, do
|
|
| 8 |
```
|
| 9 |
import torch
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
-
# The matrices are stored in space-efficient formats that're incompatible with torch's sparse csr tensor.
|
| 14 |
-
# Convert them back before constructing the matrix.
|
| 15 |
-
csr_kwargs['crow_indices'] = csr_kwargs['crow_indices'].int()
|
| 16 |
-
csr_kwargs['col_indices'] = csr_kwargs['crow_indices'].int()
|
| 17 |
-
csr_kwargs['values'] = csr_kwargs['values'].float()/255
|
| 18 |
-
|
| 19 |
-
feat_acts = torch.sparse_csr_tensor(**csr_kwargs)
|
|
|
|
| 20 |
```
|
| 21 |
|
|
|
|
| 8 |
```
|
| 9 |
import torch
|
| 10 |
|
| 11 |
+
def load_feat_acts(fname):
|
| 12 |
+
csr_kwargs = torch.load(fname)
|
| 13 |
|
| 14 |
+
# The matrices are stored in space-efficient formats that're incompatible with torch's sparse csr tensor.
|
| 15 |
+
# Convert them back before constructing the matrix.
|
| 16 |
+
csr_kwargs['crow_indices'] = csr_kwargs['crow_indices'].int()
|
| 17 |
+
csr_kwargs['col_indices'] = csr_kwargs['crow_indices'].int()
|
| 18 |
+
csr_kwargs['values'] = csr_kwargs['values'].float()/255
|
| 19 |
+
|
| 20 |
+
feat_acts = torch.sparse_csr_tensor(**csr_kwargs)
|
| 21 |
+
return feat_acts
|
| 22 |
```
|
| 23 |
|