Thank you for this nice library! I have pip installed your package and then tried to run the example code, but it crashes... It seems that this is linked to dependency issues... Is your package still maintained?
Below the error I got:
`
Gym has been unmaintained since 2022 and does not support NumPy 2.0 amongst other critical functionality.
Please upgrade to Gymnasium, the maintained drop-in replacement of Gym, or contact the authors of your software and request that they upgrade.
Users of this version of Gym should be able to simply replace 'import gym' with 'import gymnasium as gym' in the vast majority of cases.
See the migration guide at https://gymnasium.farama.org/introduction/migration_guide/ for additional information.
/Users/julietteortholqnd/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/bases/head.py:16: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import resource_filename
RuntimeError Traceback (most recent call last)
Cell In[1], line 3
1 import medkit as mk
----> 3 synthetic_dataset = mk.batch_generate(
4 domain = "Ward",
5 environment = "CRN",
6 policy = "LSTM",
7 size = 1000,
8 test_size = 200,
9 max_length = 10,
10 scale = True
11 )
13 static_train, observations_train, actions_train = synthetic_dataset['training']
14 static_test, observations_test, actions_test = synthetic_dataset['testing']
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/api.py:77, in batch_generate(domain, environment, policy, actions, size, valid_size, test_size, max_length, scale, out, confounders, overlooked, stochastic, variation, seed, **kwargs)
75 if type(environment) is str:
76 assert environment in env_dict, "Not a valid environment."
---> 77 env = env_dictenvironment
78 else:
79 assert issubclass(type(environment), BaseEnv)
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/environments/CounterfactualRNN.py:121, in CRNEnv.init(self, domain, load)
119 self.model = CRN_env(domain)
120 if load:
--> 121 self.load_pretrained()
123 self.initialiser = VAEInit(domain)
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/bases/base_env.py:30, in BaseEnv.load_pretrained(self)
24 """
25 Load pretrained model.
26 """
27 path = resource_filename(
28 "medkit", f"environments/saved_models/{self.domain.name}_{self.name}.pth"
29 )
---> 30 self.model.load_state_dict(torch.load(path))
32 return
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/torch/nn/modules/module.py:2639, in Module.load_state_dict(self, state_dict, strict, assign)
2631 error_msgs.insert(
2632 0,
2633 "Missing key(s) in state_dict: {}. ".format(
2634 ", ".join(f'"{k}"' for k in missing_keys)
2635 ),
2636 )
2638 if len(error_msgs) > 0:
-> 2639 raise RuntimeError(
2640 "Error(s) in loading state_dict for {}:\n\t{}".format(
2641 self.class.name, "\n\t".join(error_msgs)
2642 )
2643 )
2644 return _IncompatibleKeys(missing_keys, unexpected_keys)
RuntimeError: Error(s) in loading state_dict for CRN_env:
Missing key(s) in state_dict: "lstm.l0.ih.weight", "lstm.l0.ih.bias", "lstm.l0.hh.weight", "lstm.l0.hh.bias", "lstm.l1.ih.weight", "lstm.l1.ih.bias", "lstm.l1.hh.weight", "lstm.l1.hh.bias".
Unexpected key(s) in state_dict: "lstm.layers.0.cell.ih.weight", "lstm.layers.0.cell.ih.bias", "lstm.layers.0.cell.hh.weight", "lstm.layers.0.cell.hh.bias", "lstm.layers.1.cell.ih.weight", "lstm.layers.1.cell.ih.bias", "lstm.layers.1.cell.hh.weight", "lstm.layers.1.cell.hh.bias".`
Thank you for this nice library! I have pip installed your package and then tried to run the example code, but it crashes... It seems that this is linked to dependency issues... Is your package still maintained?
Below the error I got:
`
Gym has been unmaintained since 2022 and does not support NumPy 2.0 amongst other critical functionality.
Please upgrade to Gymnasium, the maintained drop-in replacement of Gym, or contact the authors of your software and request that they upgrade.
Users of this version of Gym should be able to simply replace 'import gym' with 'import gymnasium as gym' in the vast majority of cases.
See the migration guide at https://gymnasium.farama.org/introduction/migration_guide/ for additional information.
/Users/julietteortholqnd/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/bases/head.py:16: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import resource_filename
RuntimeError Traceback (most recent call last)
Cell In[1], line 3
1 import medkit as mk
----> 3 synthetic_dataset = mk.batch_generate(
4 domain = "Ward",
5 environment = "CRN",
6 policy = "LSTM",
7 size = 1000,
8 test_size = 200,
9 max_length = 10,
10 scale = True
11 )
13 static_train, observations_train, actions_train = synthetic_dataset['training']
14 static_test, observations_test, actions_test = synthetic_dataset['testing']
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/api.py:77, in batch_generate(domain, environment, policy, actions, size, valid_size, test_size, max_length, scale, out, confounders, overlooked, stochastic, variation, seed, **kwargs)
75 if type(environment) is str:
76 assert environment in env_dict, "Not a valid environment."
---> 77 env = env_dictenvironment
78 else:
79 assert issubclass(type(environment), BaseEnv)
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/environments/CounterfactualRNN.py:121, in CRNEnv.init(self, domain, load)
119 self.model = CRN_env(domain)
120 if load:
--> 121 self.load_pretrained()
123 self.initialiser = VAEInit(domain)
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/medkit/bases/base_env.py:30, in BaseEnv.load_pretrained(self)
24 """
25 Load pretrained model.
26 """
27 path = resource_filename(
28 "medkit", f"environments/saved_models/{self.domain.name}_{self.name}.pth"
29 )
---> 30 self.model.load_state_dict(torch.load(path))
32 return
File ~/miniforge3/envs/medkit2/lib/python3.10/site-packages/torch/nn/modules/module.py:2639, in Module.load_state_dict(self, state_dict, strict, assign)
2631 error_msgs.insert(
2632 0,
2633 "Missing key(s) in state_dict: {}. ".format(
2634 ", ".join(f'"{k}"' for k in missing_keys)
2635 ),
2636 )
2638 if len(error_msgs) > 0:
-> 2639 raise RuntimeError(
2640 "Error(s) in loading state_dict for {}:\n\t{}".format(
2641 self.class.name, "\n\t".join(error_msgs)
2642 )
2643 )
2644 return _IncompatibleKeys(missing_keys, unexpected_keys)
RuntimeError: Error(s) in loading state_dict for CRN_env:
Missing key(s) in state_dict: "lstm.l0.ih.weight", "lstm.l0.ih.bias", "lstm.l0.hh.weight", "lstm.l0.hh.bias", "lstm.l1.ih.weight", "lstm.l1.ih.bias", "lstm.l1.hh.weight", "lstm.l1.hh.bias".
Unexpected key(s) in state_dict: "lstm.layers.0.cell.ih.weight", "lstm.layers.0.cell.ih.bias", "lstm.layers.0.cell.hh.weight", "lstm.layers.0.cell.hh.bias", "lstm.layers.1.cell.ih.weight", "lstm.layers.1.cell.ih.bias", "lstm.layers.1.cell.hh.weight", "lstm.layers.1.cell.hh.bias".`