Skip to content

Commit

Permalink
Update numpy.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Sep 21, 2024
1 parent 4bb2e65 commit abe90dc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions source/numpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ numpy.ModelFactory = class {
case 'npz': {
format = 'NumPy Zip';
const layers = new Map();
for (const [key, array] of context.target) {
const entries = Array.from(context.target);
const separator = entries.every(([name]) => name.endsWith('.weight.npy')) ? '.' : '/';
for (const [key, array] of entries) {
const name = key.replace(/\.npy$/, '');
const parts = name.split('/');
const parameterName = parts.pop();
const groupName = parts.join('/');
const path = name.split(separator);
const parameterName = path.pop();
const groupName = path.join(separator);
if (!layers.has(groupName)) {
layers.set(groupName, { name: groupName, parameters: [] });
}
Expand Down

0 comments on commit abe90dc

Please # to comment.