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

it occur a error when read weights.h5py #218

Open
ttjjlw opened this issue Sep 26, 2019 · 0 comments
Open

it occur a error when read weights.h5py #218

ttjjlw opened this issue Sep 26, 2019 · 0 comments

Comments

@ttjjlw
Copy link

ttjjlw commented Sep 26, 2019

    with h5py.File(weight_file, 'r') as fin:
        if varname_in_file == 'char_embed':
            # Have added a special 0 index for padding not present
            # in the original model.
            char_embed_weights = fin[varname_in_file][...]
            weights = np.zeros(
                (char_embed_weights.shape[0] + 1,
                 char_embed_weights.shape[1]),
                dtype=DTYPE
            )
            weights[1:, :] = char_embed_weights
        else:
            weights = fin[varname_in_file][...]

'but occur a error: '

File "D:\localE\code\daguang_extract\daguan_elmo_ner-master\daguan_elmo_ner-master\bilm\model.py", line 225, in _pretrained_initializer
  weights = fin[varname_in_file][...]
File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "D:\Python_\lib\site-packages\h5py\_hl\group.py", line 264, in __getitem__
  oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
File "h5py\_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py\_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5o.pyx", line 190, in h5py.h5o.open
KeyError: 'Unable to open object (component not found)'

options.json : {"lstm": {"proj_clip": 3, "projection_dim": 512, "n_layers": 3, "dim": 4096, "use_skip_connections": true, "cell_clip": 3}, "n_negative_samples_batch": 8192, "n_train_tokens": 94268535, "dropout": 0.1, "n_epochs": 50, "all_clip_norm_val": 10.0, "bidirectional": true, "unroll_steps": 20, "batch_size": 128, "n_tokens_vocab": 21206, "char_cnn": {"filters": [[1, 32], [2, 32], [3, 64], [4, 128], [5, 256], [6, 512], [7, 1024]], "n_highway": 2, "activation": "relu", "max_characters_per_token": 7, "n_characters": 262, "embedding": {"dim": 16}}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant