我正在尝试测试Keras和TensorFlow是否可以在具有32GB RAM的最新Mojave上的MacBook Pro上正常工作,显然不是!
我尝试将它们安装在单独的新环境中,但效果很好,但我不明白为什么它在我的基本(根)环境中不起作用。
analytics.track(action, {'category': category, **kwargs})
我希望得到这个结果,这是在干净的环境中完成的:
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import to_categorical
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.datasets import make_regression
X, y = make_regression(n_samples=1000, n_features=20)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
ss = StandardScaler()
X_train_sc = ss.fit_transform(X_train)
X_test_sc = ss.transform(X_test)
model = Sequential()
model.add(Dense(32, input_dim=20, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(X_train_sc, y_train, validation_data=(X_test_sc, y_test), epochs=10, batch_size=32)
但是,我只得到了这个:
WARNING:tensorflow:From /Users/Hovanes/anaconda3/envs/clean/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
Train on 750 samples, validate on 250 samples
Epoch 1/10
2019-04-26 19:04:32.220021: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
750/750 [==============================] - 0s 235us/step - loss: 30460.2991 - val_loss: 30451.6543
Epoch 2/10
750/750 [==============================] - 0s 23us/step - loss: 30384.4905 - val_loss: 30375.6350
Epoch 3/10
750/750 [==============================] - 0s 22us/step - loss: 30292.1559 - val_loss: 30280.5673
Epoch 4/10
750/750 [==============================] - 0s 23us/step - loss: 30162.1524 - val_loss: 30141.1293
Epoch 5/10
750/750 [==============================] - 0s 22us/step - loss: 29971.8937 - val_loss: 29918.3467
Epoch 6/10
750/750 [==============================] - 0s 23us/step - loss: 29689.4520 - val_loss: 29591.1545
Epoch 7/10
750/750 [==============================] - 0s 22us/step - loss: 29266.3404 - val_loss: 29122.6358
Epoch 8/10
750/750 [==============================] - 0s 22us/step - loss: 28671.3374 - val_loss: 28470.9937
Epoch 9/10
750/750 [==============================] - 0s 23us/step - loss: 27898.4042 - val_loss: 27585.4375
Epoch 10/10
750/750 [==============================] - 0s 22us/step - loss: 26869.9945 - val_loss: 26530.5343
<keras.callbacks.History object at 0x136d07630>
我使用完全相同的安装方法(pip)在完全相同的计算机上运行了完全相同的代码。
任何人和所有帮助将不胜感激!
答案 0 :(得分:0)
无法复制错误,我在manjaro中使用了python 3.6.7和3.7.3。 要下载我使用的软件包:
conda install -c conda-forge jupyterlab scikit-learn keras
您能告诉我如何安装这些库吗?否则,您可以尝试使用上面的命令来安装库。
如果不起作用,可能是其他原因。
答案 1 :(得分:0)
所以,问题是pip安装...我卸载了所有内容,并通过conda-forge安装了它,终于可以了。希望它对将来遇到此问题的人有所帮助!