Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of from keras import backend as K error in keras

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to solve from keras import backend as K errors in keras". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction of principle

Keras is a module-based advanced deep learning development framework. It does not only rely on a certain high-speed low-level tensor library, but encapsulates a variety of low-level tensor libraries by high-level modules, allowing the underlying library to complete operations such as tensor product and convolution.

Currently, Keras provides three backend implementations: TensorFlow backend, Theano backend, and CNTK backend.

TensorFlow is an open source symbol tensor manipulation framework developed by Google.

Theano is an open source symbolic tensor manipulation framework developed by LISA Lab of the University of Montreal.

CNTK is an open source toolkit for deep learning developed by Microsoft.

Meaning

That is, you can write new code using the abstract Keras backend.

The following code instantiates the input placeholder. It is equivalent to tf.placeholder () or th.tensor.matrix (), th.tensor.tensor3 (), and so on.

Inputs = K.placeholder (shape= (2,4,5)) # also works:inputs = K.placeholder (shape= (None, 4,5)) # also works:inputs = K.placeholder (ndim=3)

Add: keras, from keras import backend as K reported an error

If you encounter an error in from keras import backend as K, it may be because "backend" in the keras.json file is not set to mxnet or tensorflow, etc.

Solution: 1. Modify Backend: find this file ~ / .keras/keras.json

Secondly, modify the framework behind backend to mxnet or tensorflow.

Cd ~ / .kerasvim keras.json#-- {# keras.json file content "image_dim_ordering": "tf", "epsilon": 1e-07, "floatx": "float32", "backend": "theano"}

If option 1 cannot solve the problem, you can try option 2.

2. Add an environment variable modification statement import osos.environ ['KERAS_BACKEND'] =' tensorflow' "before import keras in the python code." how to solve the from keras import backend as K error in keras "is introduced here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report