Riskinit
Riskinit

Reputation: 97

Why does Keras model.predict never execute on this simple machine learning model I've setup?

import numpy as np
import keras as ks

model = ks.Sequential([ks.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')

xs=np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype = float)
ys=np.array([-3.0, -1.0, 1.0, 3.0, 5.0, 7.0], dtype = float)

model.fit(xs, ys, epochs=500)

print(model.predict([10.0]))

The model.predict never executes no matter how long I wait. What tests can I do to diagnose the problem? What questions should I be asking myself to find the issue?

Upvotes: 0

Views: 33

Answers (2)

Riskinit
Riskinit

Reputation: 97

I went back and fixed my build?

First I reinstalled tensorflow. My original command was:

pip install tensorflow-gpu==2.0

Which I did an install using the following:

pip install tensorflow

And then I made sure to follow the following steps for Windows.

https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html

Upvotes: 1

Mike Dunn
Mike Dunn

Reputation: 90

Code is ok -- ran in less than 1 second for me.

6/6 [==============================] - 0s 101us/step - loss: 4.8739e-05
Epoch 500/500

6/6 [==============================] - 0s 115us/step - loss: 4.7737e-05
[[18.979841]]

Process finished with exit code 0

Upvotes: 1

Related Questions