简体   繁体   English

Keras坚持第一纪元

[英]Keras Stuck on First Epoch

I was trying to test out whether Keras and TensorFlow are working on my MacBook Pro on the latest Mojave with 32GB of RAM and apparently it is not! 我试图测试Keras和TensorFlow是否在最新的Mojave上运行我的MacBook Pro,内存为32GB,显然它不是!

I tried installing them in a separate, new environment, and it worked fine, but I don't understand why it won't work in my base (root) environment. 我尝试在一个单独的新环境中安装它们,它工作正常,但我不明白为什么它不能在我的基础(根)环境中工作。

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)

I expected to get this result, which I did in my clean environment: 我希望得到这个结果,我在干净的环境中做了这个结果:

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>

But instead, I only got this: 但相反,我只有这个:

WARNING:tensorflow:From /Users/Hovanes/anaconda3/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

I ran the exact same code on the exact same computer using the exact same installation method (pip). 我使用完全相同的安装方法(pip)在完全相同的计算机上运行完全相同的代码。

Any and all help would be greatly appreciated! 任何和所有的帮助将不胜感激!

Couldn't replicate the error, I used python 3.6.7 and 3.7.3 in manjaro. 无法复制错误,我在manjaro中使用了python 3.6.7和3.7.3。 To download the packages I used: 要下载我使用的软件包:

conda install -c conda-forge jupyterlab scikit-learn keras conda install -c conda-forge jupyterlab scikit-learn keras

Can you tell me how you installed the libraries? 你能告诉我你是如何安装这些库的吗? Otherwise you can try using the command above to install the libraries. 否则,您可以尝试使用上面的命令来安装库。

If it doesn't work could be something else. 如果它不起作用可能是别的。

So, the problem was pip install... I uninstalled everything and installed it through conda-forge and it finally worked. 所以,问题是pip install ...我卸载了所有东西并通过conda-forge安装它,它终于工作了。 Hope it helps those who run into this issue in the future! 希望它能帮助那些将来遇到这个问题的人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM