I would like to make a neural network which has several inputs and 3 outputs but when I try to put 2 entries in my program it does not want.
import keras
import numpy as np
import tensorflow as tf
model = keras.Sequential(
[
tf.keras.layers.Dense(units=5, input_shape=[2]),
tf.keras.layers.Dense(units=1, input_shape=[5]),
]
)
model.compile('sgd', loss='mean_squared_error')
# Call model on a test input
x = np.array([0.0,1.0,2.0,3.0,4.0,5.0,6.0])
x2 = np.array([2.0,3.0,4.0,5.0,6.0,7.0,8.0])
y = np.array([1.0,2.0,3.0,4.0,5.0,6.0,7.0])
model.fit(x=[x,x2], y=y, epochs=3000)
print(model.predict([10.0]))
And I have this as an error I have already been looked at but nothing related to what I want to do:
2022-08-19 15:57:56.968978: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-08-19 15:57:57.249294: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5501 MB memory: -> device: 0, name: NVIDIA GeForce RTX 3060 Ti, pci bus id: 0000:05:00.0, compute capability: 8.6
Epoch 1/3000
Traceback (most recent call last):
File "C:\Users\goran\PycharmProjects\AI_crypto\main.py", line 18, in <module>
model.fit(x=[x,x2], y=y, epochs=3000)
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\framework\func_graph.py", line 1147, in autograph_handler
raise e.ag_error_metadata.to_exception(e)
ValueError: in user code:
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\training.py", line 1021, in train_function *
return step_function(self, iterator)
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\training.py", line 1010, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\training.py", line 1000, in run_step **
outputs = model.train_step(data)
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\training.py", line 859, in train_step
y_pred = self(x, training=True)
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\goran\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\input_spec.py", line 200, in assert_input_compatibility
raise ValueError(f'Layer "{layer_name}" expects {len(input_spec)} input(s),'
ValueError: Layer "sequential" expects 1 input(s), but it received 2 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None,) dtype=float32>, <tf.Tensor 'IteratorGetNext:1' shape=(None,) dtype=float32>]
Process finished with exit code 1