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

Tensorflow 2.16.1 compatibility #234

Closed
Stikus opened this issue Mar 14, 2024 · 4 comments
Closed

Tensorflow 2.16.1 compatibility #234

Stikus opened this issue Mar 14, 2024 · 4 comments

Comments

@Stikus
Copy link

Stikus commented Mar 14, 2024

Hello, as you can see in pVACtools issue griffithlab/pVACtools#1084 - mhcflurry and/or https://github.com/KarchinLab/mhcnuggets doesn't work with latest 2.16.1 version of tensorflow.

Exception: An error occurred while calling MHCflurry:
Traceback (most recent call last):
  File "/usr/local/bin/mhcflurry-predict", line 8, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.10/dist-packages/mhcflurry/predict_command.py", line 204, in run
    predictor = Class1PresentationPredictor.load(models_dir)
  File "/usr/local/lib/python3.10/dist-packages/mhcflurry/class1_presentation_predictor.py", line 956, in load
    affinity_predictor = Class1AffinityPredictor.load(
  File "/usr/local/lib/python3.10/dist-packages/mhcflurry/class1_affinity_predictor.py", line 608, in load
    optimized = result.optimize()
  File "/usr/local/lib/python3.10/dist-packages/mhcflurry/class1_affinity_predictor.py", line 653, in optimize
    Class1NeuralNetwork.merge(
  File "/usr/local/lib/python3.10/dist-packages/mhcflurry/class1_neural_network.py", line 1148, in merge
    configure_tensorflow()
  File "/usr/local/lib/python3.10/dist-packages/mhcflurry/common.py", line 131, in configure_tensorflow
    tensorflow.compat.v1.keras.backend.set_session(session)
AttributeError: module 'keras._tf_keras.keras.backend' has no attribute 'set_session'. Did you mean: 'set_epsilon'?

Looks like some legacy code stopped working - maybe tensorflow version should be pinned until code is fixed?

@timodonnell
Copy link
Contributor

Thanks for letting us know - will fix this

@Stikus
Copy link
Author

Stikus commented Mar 14, 2024

@timodonnell Thanks for fast answer. I should double-check first - pVACtools still using mhcflurry 2.0.6 - https://github.com/griffithlab/pVACtools/blob/master/setup.py#L90, maybe this problem is already fixed in latest version.

@timodonnell
Copy link
Contributor

Ah ok yes was just seeing that - I think it should be already fixed in the latest.

@timodonnell
Copy link
Contributor

While the set_session issue in your stack trace is already fixed, I'm seeing other failures when running using tensorflow==2.16.1 (stack traces below). So I think we should still release a new mhcflurry with the tensorflow version pinned.

        if self.hyperparameters["learning_rate"] is not None:
            K.set_value(
                self.network().optimizer.lr, self.hyperparameters["learning_rate"]
            )
>       fit_info["learning_rate"] = float(K.get_value(self.network().optimizer.lr))
E       AttributeError: 'RMSprop' object has no attribute 'lr'

mhcflurry/class1_neural_network.py:896: AttributeError
        for i, locally_connected_params in enumerate(locally_connected_layers):
>           current_layer = keras.layers.LocallyConnected1D(
                name="lc_%d" % i, **locally_connected_params
            )(current_layer)
E           AttributeError: module 'tensorflow.keras.layers' has no attribute 'LocallyConnected1D'

mhcflurry/class1_neural_network.py:1365: AttributeError

Also if anyone can suggest the fix for these issues so we can support the latest tf, ideally preserving some compatibility with earlier tf versions, please let me know.

timodonnell added a commit that referenced this issue Mar 14, 2024
Set upper limit on tensorflow version. Fixes #234
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

2 participants