在运行旧脚本时,更新keras和tensorflow后,我遇到以下错误:
final NotesAdapter notesAdapter=new NotesAdapter(list,this);
recyclerView.setAdapter(notesAdapter);
FloatingActionButton fab = findViewById(R.id.fab);
firebaseDatabase=FirebaseDatabase.getInstance();
databaseReference=firebaseDatabase.getReference("Posts");
Query query = databaseReference.orderByKey();
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot dataSnapshot1: dataSnapshot.getChildren())
{
Listdata listdata=dataSnapshot1.getValue(Listdata.class);
list.add(listdata);
}
notesAdapter.notifyDataSetChanged();
}
对于以下代码行
module 'keras.backend' has no attribute 'tensorflow_backend'
我了解到这可能是版本不匹配的问题。 Keras 和 Tensorflow 的相应版本是
print(K.tensorflow_backend._get_available_gpus())
为克服此错误,我应该使用什么正确的版本兼容性/组合?
答案 0 :(得分:3)
tensorflow_backend._get_available_gpus()
在tensorflow 2.0中不可用。
您最好的选择是使用tf.config.list_physical_devices
或tf.config.experimental.list_physical_devices
GPU_list = tf.config.list_physical_devices('GPU')
# OR
GPU_list = tf.config.experimental.list_physical_devices('GPU')
答案 1 :(得分:1)
您的TensorFlow版本错误
安装
TensorFlow Core v2.2.0
Python
此版本包含tf.keras.backend.backend()
https://www.tensorflow.org/api_docs/python/tf/keras/backend
我希望这会有所帮助