After working with the tensorflow’s example tutorial on colab: Basic regression: Predict fuel efficiency, which can be found here: https://www.tensorflow.org/tutorials/keras/regression.
I’ve been trying to run this example on jupyter notebook via anaconda in order to be able to run it offline too.
The code that one can find on the link works fine on google colab, but when I try to run it on jupyter notebook I get a vector of nan’s.
- A run on google colab yields:
Running the example on google colab - A run on jupyter yields:
Running the example on jupyter lab
The code for building the sequential model: [where the problem might come from]
horsepower_model = tf.keras.Sequential([ horsepower_normalizer, layers.Dense(units=1) ]) horsepower_model.summary()
The rest of the code can be found in this link that I have attached above:
https://www.tensorflow.org/tutorials/keras/regression
What the model has to do:
This model takes 2 arrays from a dataset: MPG and Horsepower, and is about to use single-variable linear regression in order to predict MPG from Horsepower.
Therefore, the model is introduce a Dense layer with shape of 1 as one can see from here:
layers.Dense(units=1)
The output of the model should be the values of the MPG, based on the horsepower values.
Then we will be able to compare it with the values of the real MPG that we’ve got from the dataset.
Thank you in advance.
EDIT: I upload my notebook:
https://www.udrop.com/Jk3/Horsepower.ipynb
Advertisement
Answer
I see you are using different models in them. In Colab you have used model having only 5 parameters whereas in Notebook you are using a dense model having 944 parameters.
Try running the model with less parameter on notebook first or Try running the same model on both.(Maybe the complex model was not trained completely.)
EDIT 1: I have created a jupyter notebook and tried the code. In my system it is working fine, try running this jupyter notebook in your system. Jupyter Notebook . If it works then maybe there is some syntax error in your code.
EDIT 2: Update tensorflow:
pip install --ignore-installed --upgrade tensorflow
use this or any other command that works on your version.