What am I doing wrong?
https://repl.it/@zbitname/outputnamesproblem
import tensorflow as tf
import numpy as np
def random_generator():
while True:
yield ({"input_1": np.random.randint(1, 10000), "input_2": np.random.randint(1, 10000)}, {"output": np.random.randint(0, 1)})
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(16, activation=tf.nn.tanh))
model.add(tf.keras.layers.Dense(4, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(1, activation=tf.nn.sigmoid))
model.build((1000, 2))
categories_train = random_generator()
model.compile(
optimizer='sgd',
loss='categorical_crossentropy',
metrics=['accuracy']
)
model.fit_generator(
generator=categories_train,
use_multiprocessing=True,
workers=6,
steps_per_epoch=10000
)
Actual results
OS: Windows 10
python.exe --version > Python 3.6.7 python.exe -c 'import tensorflow as tf; print(tf.VERSION)' > 1.12.0 python.exe bug.py Traceback (most recent call last): File "bug.py", line 21, in metrics=['accuracy'] File "C:\Users\***\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\training\checkpointable\base.py", line 474, in _method_wrapper method(self, *args, **kwargs) File "C:\Users\***\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\keras\engine\training.py", line 600, in compile skip_target_weighing_indices) File "C:\Users\***\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\keras\engine\training.py", line 134, in _set_sample_weight_attributes self.output_names, sample_weight_mode, skip_target_weighing_indices) AttributeError: 'Sequential' object has no attribute 'output_names'
OS: Ubuntu
$ cat /etc/lsb-release > DISTRIB_ID=Ubuntu > DISTRIB_RELEASE=16.04 > DISTRIB_CODENAME=xenial > DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS" $ python3.6 --version > Python 3.6.8 $ python -c 'import tensorflow as tf; print(tf.VERSION)' > 1.12.0 $ python3.6 bug.py Traceback (most recent call last): File "bug.py", line 21, in metrics=['accuracy'] File "/home/***/.local/lib/python3.6/site-packages/tensorflow/python/training/checkpointable/base.py", line 474, in _method_wrapper method(self, *args, **kwargs) File "/home/***/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 600, in compile skip_target_weighing_indices) File "/home/***/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 134, in _set_sample_weight_attributes self.output_names, sample_weight_mode, skip_target_weighing_indices) AttributeError: 'Sequential' object has no attribute 'output_names'