Shape problems in LSTM; Configuring LSTM properly in Keras
@flexorcist,
Your input needs to be reshaped.
**input_shape: A 3D tensor with shape [batch, timesteps, features]**

Keras' convention is that the batch dimension (number of examples (not the same as timesteps)) is typically omitted in the input_shape arguments. The batching (number of examples per batch) is handled in the fit call.

Also please take a look at this SO [link](https://stackoverflow.com/questions/44583254/valueerror-input-0-is-incompatible-with-layer-lstm-13-expected-ndim-3-found-n) and the https://github.com/keras-team/keras/issues/7403 with the similar error. Thank you! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62270">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62270">No</a>

### Issue type

Support

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

tf 2.8

### Custom code

Yes

### OS platform and distribution

Windows 11

### Mobile device

_No response_

### Python version

3.10

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

So I wanted to make a neural network that predicts weather on python. It should take data on previous 30 days as input and make a prediction on how many % (+ or -) will the air temperature change. Neural network will compute 2 inputs, so data on a single day looks like this:

1-st input:
[20, 72, 1]

First entry is temperature, second is humidity and third is atmospheric pressure. 


2-nd input:
[*Weather observations*]

[*Weather observations*] array contains long strings of weather observations. In this array there may be one observation, may be more than one or none.


One complete unit of training data for 30-ty days looks like this:

1-st input:
[ [20, 72, 1], #1-st day
  [15, 89, 1.03], #2-nd day
  [19, 79, 1.01], #3-d day
  [24, 67, 0.98], #...
  ...
  ... ]

2-nd input:

[ ["Many cloudy spots...", "Today we had experienced..."], #1-st day
  ["Rain has been going for..."], #2-nd day
  [""], #3-d day
  ["In following regions...", "Cause of geomagnetic...", "Today is one of the sunniest...], #...
  ...
  ... ]

So both of those input units contains thirty entries like this (becuase of mentioned 30-ty days), and the label for this unit is air temperature on the day that is a week ahead of the last entry.


Summarizing, the inputs will be lists of lists, where each list contains device readings/weather observations for 30 days with daily readings/observations placed in another list inside. So, first element in the second group of 30 days will be a set of observations which is second element in the first group of 30 days (aka 3-rank list, I hope you got it).

I wrote the following model:

### Standalone code to reproduce the issue

```shell
embedding_dim = 128  
vocab_size = len(words_to_int)  # number of unique words

num_input = keras.Input(shape= (30,3), name="nums")
nmlstm = layers.LSTM(64)(num_input) #num input goes to num lstm
nmdense = layers.Dense(64)(nmlstm) #num lstm goes to num dense

text_input = keras.Input(shape= (30, max_sequence_length), name="text") #basically length of the longest string observation sequence 

text_vec = layers.Embedding(vocab_size, embedding_dim, mask_zero=True)(text_input) #text input goes to text embedding
txlstm = layers.LSTM(64)(text_vec) #text embedding goes to text lstm


united = layers.concatenate([nmdense, txlstm]) #concatenating text lstm and num dense
almostlast = layers.Dense(64)(united) #computing united input 
last = layers.Dense(2, name='prediction')(almostlast) #output dense layer

model = keras.Model(inputs=[num_input, text_input], outputs=last)
model.compile(optimizer='adam', loss=keras.losses.CategoricalCrossentropy)
model.fit(
    {"nums": X1_train, "text": X2_train},
    {"prediction": y_train},
    epochs=8,
    batch_size=10)
```
```


### Relevant log output

```shell
When I try to run the code, I get this error:

ValueError: Input 0 of layer "lstm_1" is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 30, 2, 128)


I tried changing the input shape of text_input, but I kept on getting the same error.
To mention, I didn't have any problems on encoding data, padding it etc. Also it's better if there's a way of fixing it without changing the shape of 2-nd input data because the main goal is to make the neural network treat 30-day data as one input and providing only one output (how many % (+ or -) the air temperature will change) while learning on text observations to make predictions also based on them. Thank you in advance.
```
