ModuleNotFoundError: No module named ‘keras.api‘解决

重点在于import tensorflow.keras (可行)
我在 cmd 和notebook都试了
cmd的:            ^
SyntaxError: invalid syntax
>>> import tensorflow as tf
2022-04-12 15:12:12.866276: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-04-12 15:12:12.866432: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
>>>
>>>
>>> a = tf.random.uniform([4,10])
2022-04-12 15:12:35.790241: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2022-04-12 15:12:35.790398: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
2022-04-12 15:12:35.794124: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: LAPTOP-RS017NRJ
2022-04-12 15:12:35.794342: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: LAPTOP-RS017NRJ
2022-04-12 15:12:35.795301: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
>>> print(a)
tf.Tensor(
[[0.8562763  0.74294853 0.3382907  0.06466854 0.1204735  0.52903223
  0.85028434 0.64586246 0.1983546  0.07855964]
 [0.43987226 0.3635075  0.52682006 0.28708458 0.8067572  0.15162098
  0.8284776  0.62292194 0.54997706 0.50583315]
 [0.34328866 0.1397022  0.8850664  0.9506463  0.7170223  0.13799334
  0.17858255 0.7092109  0.86810756 0.9444325 ]
 [0.97939897 0.5265962  0.97248435 0.70333874 0.8734523  0.3986025
  0.01936245 0.07984626 0.59270334 0.48528957]], shape=(4, 
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值