You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am relatively new but I did search everywhere for a solution to my problem but can't find any answers
anywhere. I run Windows 10 with Anaconda3 and Python 3 and Tensor flow as a backend to Keras. The
first program I tried worked very well but just today non of my Keras programs work. I get the same
error message for all of my programs: AttributeError: module 'tensorflow' has no attribute 'placeholder'
I don't even know how to get started to fix this kind of error? If anyone could help, it would be a
lifesaver for a science project for my son.
Ray Van Raamsdonk
#keras2.py
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
target_data = np.array([[0],[1],[1],[0]], "float32")
model = Sequential()
model.add(Dense(3, input_dim=2, activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['binary_accuracy'])
model.fit(training_data, target_data, epochs=5000, verbose=2)
#Get the weights
for layer in model.layers:
weights = layer.get_weights() # list of numpy arrays
print(model.predict(training_data))
~\keras2.py in ()
1 #keras2.py
2 import numpy as np
----> 3 from keras.models import Sequential
4 from keras.layers.core import Activation, Dense
5 training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras_init_.py in ()
1 from future import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras\utils_init_.py in ()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras\utils\conv_utils.py in ()
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
This happened once to me too, but a long time ago. I suggest you uninstall keras and tensorflow, update all packages in anaconda and then reinstall tensorflow and keras. As much as remember, it worked for me at that time.
Let us know if it works.
________________________________
From: Sai Raj Kishore <notifications@github.com>
Sent: February 27, 2018 9:39 AM
To: keras-team/keras
Cc: RayVanRaamsdonk; Author
Subject: Re: [keras-team/keras] AttributeError: module 'tensorflow' has no attribute 'placeholder' (#9501)
This happened once to me too, but a long time ago. I suggest you uninstall keras and tensorflow, update all packages in anaconda and then reinstall tensorflow and keras. As much as remember, it worked for me at that time.
Let us know if it works.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#9501 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AhO-mqThPRAXOvxlQ5GUfqqReJijM52Nks5tY81ggaJpZM4SUhTV>.
Hello,
I am relatively new but I did search everywhere for a solution to my problem but can't find any answers
anywhere. I run Windows 10 with Anaconda3 and Python 3 and Tensor flow as a backend to Keras. The
first program I tried worked very well but just today non of my Keras programs work. I get the same
error message for all of my programs: AttributeError: module 'tensorflow' has no attribute 'placeholder'
I don't even know how to get started to fix this kind of error? If anyone could help, it would be a
lifesaver for a science project for my son.
Ray Van Raamsdonk
#keras2.py
import numpy as np
from keras.models import Sequential
from keras.layers.core import Activation, Dense
training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
target_data = np.array([[0],[1],[1],[0]], "float32")
model = Sequential()
model.add(Dense(3, input_dim=2, activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['binary_accuracy'])
model.fit(training_data, target_data, epochs=5000, verbose=2)
#Get the weights
for layer in model.layers:
weights = layer.get_weights() # list of numpy arrays
print(model.predict(training_data))
import keras2
Using TensorFlow backend.
AttributeError Traceback (most recent call last)
in ()
----> 1 import keras2
~\keras2.py in ()
1 #keras2.py
2 import numpy as np
----> 3 from keras.models import Sequential
4 from keras.layers.core import Activation, Dense
5 training_data = np.array([[0,0],[0,1],[1,0],[1,1]], "float32")
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras_init_.py in ()
1 from future import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras\utils_init_.py in ()
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7
8 # Globally-importable utils.
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras\utils\conv_utils.py in ()
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras\backend_init_.py in ()
81 elif _BACKEND == 'tensorflow':
82 sys.stderr.write('Using TensorFlow backend.\n')
---> 83 from .tensorflow_backend import *
84 else:
85 raise ValueError('Unknown backend: ' + str(_BACKEND))
c:\users\ray van\anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py in ()
3 from future import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.training import moving_averages
7 from tensorflow.python.ops import tensor_array_ops
~\tensorflow.py in ()
16 plt.scatter(xs, ys)
17
---> 18 X = tf.placeholder(tf.float32, shape=(None,), name="x")
19 Y = tf.placeholder(tf.float32, shape=(None,), name="y")
20 w = tf.Variable([0., 0.], name="parameter", trainable=True)
AttributeError: module 'tensorflow' has no attribute 'placeholder'
The text was updated successfully, but these errors were encountered: