I am trying to reproduce your example and ended up with the following error. How can I resolve this? thanks.
code
from numpy import loadtxt
dataset = loadtxt("https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv", delimiter=",")
x = dataset[:,0:8]
y = dataset[:, 8]
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
def diabetes():
model = Sequential()
model.add(Dense(12, input_dim=8, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(X, Y, epochs=100, batch_size=10, verbose=0)
return model
from tensorflow.keras.activations import relu, elu
p = {
'first_neuron': [12, 24, 48],
'activation': ['relu', 'elu'],
'batch_size': [10, 20, 30]
}
# add input parameters to the function
def diabetes(x_train, y_train, x_val, y_val, params):
# replace the hyperparameter inputs with references to params dictionary
model = Sequential()
model.add(Dense(params['first_neuron'], input_dim=8, activation=params['activation']))
#model.add(Dense(8, activation=params['activation']))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# make sure history object is returned by model.fit()
out = model.fit(x=x,
y=y,
validation_data=[x_val, y_val],
epochs=100,
batch_size=params['batch_size'],
verbose=0)
# modify the output model
return out, model
import talos
t = talos.Scan(x=x, y=y, params=p, model=diabetes, experiment_name='diabetes')
error
talos % python test.py
Using TensorFlow backend.
0%| | 0/18 [00:00<?, ?it/s]2020-11-23 17:21:01.413704: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-11-23 17:21:01.444795: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fcb9a649100 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-11-23 17:21:01.444823: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
File "test.py", line 55, in <module>
t = talos.Scan(x=x, y=y, params=p, model=diabetes, experiment_name='diabetes')
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/talos/scan/Scan.py", line 196, in __init__
scan_run(self)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/talos/scan/scan_run.py", line 26, in scan_run
self = scan_round(self)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/talos/scan/scan_round.py", line 19, in scan_round
self.model_history, self.round_model = ingest_model(self)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/talos/model/ingest_model.py", line 10, in ingest_model
self.round_params)
File "test.py", line 47, in diabetes
verbose=0)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 108, in _method_wrapper
return method(self, *args, **kwargs)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1133, in fit
return_dict=True)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 108, in _method_wrapper
return method(self, *args, **kwargs)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1379, in evaluate
tmp_logs = test_function(iterator)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 780, in __call__
result = self._call(*args, **kwds)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 823, in _call
self._initialize(args, kwds, add_initializers_to=initializers)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 697, in _initialize
*args, **kwds))
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 2855, in _get_concrete_function_internal_garbage_collected
graph_function, _, _ = self._maybe_define_function(args, kwargs)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 3213, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 3075, in _create_graph_function
capture_by_value=self._capture_by_value),
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py", line 986, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 600, in wrapped_fn
return weak_wrapped_fn().__wrapped__(*args, **kwds)
File "/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/framework/func_graph.py", line 973, in wrapper
raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:1224 test_function *
return step_function(self, iterator)
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:1215 step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/distribute/distribute_lib.py:1211 run
return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/distribute/distribute_lib.py:2585 call_for_each_replica
return self._call_for_each_replica(fn, args, kwargs)
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/distribute/distribute_lib.py:2945 _call_for_each_replica
return fn(*args, **kwargs)
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:1208 run_step **
outputs = model.test_step(data)
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py:1174 test_step
y_pred = self(x, training=False)
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py:976 __call__
self.name)
/Users/gireeshbogu/miniconda2/lib/python3.6/site-packages/tensorflow/python/keras/engine/input_spec.py:158 assert_input_compatibility
' input tensors. Inputs received: ' + str(inputs))
ValueError: Layer sequential expects 1 inputs, but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, 8) dtype=float32>, <tf.Tensor 'ExpandDims:0' shape=(None, 1) dtype=float32>]
0%| | 0/18 [00:01<?, ?it/s]
I am trying to reproduce your example and ended up with the following error. How can I resolve this? thanks.
code
error