如何使用Mac上安装的TensorFlow运行代码?
我正在运行代码,并且有Mac。我正在尝试培训人工神经网络。我想使用Keras。
我编写了此代码:
有以下错误:
modulenotfounderror trackback(最近的最新通话) 输入[1],in<单元线:13>() 11来自Sklearn.Perprecorsing进口标准标准 12来自numpy import loadtxt ---> 13导入TensorFlow作为TF 14来自TensorFlow Import Keras 16 Start ='2017-06-26'ModulenotFoundError
:没有名为“ TensorFlow”的模块
,但我得到了以下内容,因此存在Tensoflow。我可以改变什么?我必须更改安装的版本吗?还是我们必须放一个图书馆?任何提示都将不胜感激
。 名称:TensorFlow 版本:0.12.0 摘要:TensorFlow有助于张量流动 主页:
你有一个主意吗?
代码:
import tensorflow as tf
from tensorflow import keras
from keras.models import Sequential
from keras.layers import Dense, Activation
model = Sequential()
model.add(Dense(2, input_shape=(2,)))
model.add(Activation('sigmoid'))
model.add(Dense(1))
model.add(Activation('sigmoid'))
model.compile(loss='mean_squared_error', optimizer='sgd', metrics=['accuracy'])```
I am running a code and I have MAC.I am trying to train an Artificial Neural Network. I thought to use keras.
I have written this code:
There is the following error:
ModuleNotFoundError Traceback (most recent call last)
Input In [1], in <cell line: 13>()
11 from sklearn.preprocessing import StandardScaler
12 from numpy import loadtxt
---> 13 import tensorflow as tf
14 from tensorflow import keras
16 start='2017-06-26'
ModuleNotFoundError: No module named 'tensorflow'
But I get the following, so tensoflow exists. What can I change? Do I have to change the version that is installed? Or do we have to put another library? Any hint will be appreciated....
pip show tensorflow
Name: tensorflow
Version: 0.12.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /opt/homebrew/lib/python3.9/site-packages
Requires: numpy, protobuf, six, wheel
Do you have an idea?
Code:
import tensorflow as tf
from tensorflow import keras
from keras.models import Sequential
from keras.layers import Dense, Activation
model = Sequential()
model.add(Dense(2, input_shape=(2,)))
model.add(Activation('sigmoid'))
model.add(Dense(1))
model.add(Activation('sigmoid'))
model.compile(loss='mean_squared_error', optimizer='sgd', metrics=['accuracy'])```
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用以下命令安装最新的稳定张量流版本
You need to install latest stable Tensorflow version using following commands