Untitled conversation
- User
{ "name": "NotImplementedError", "message": "Iterating over a symbolic KerasTensor is not supported.", "stack": "--------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) Cell In[33], line 5 2 batch_size = 128 4 # Instantiate the model ----> 5 model = build_model() 7 model.summary()
Cell In[32], line 10, in build_model() 6 input_shape = (6427,) 8 inputs = Input(shape=input_shape) ---> 10 model = Sequential([ 11 Dense(6427, activation='relu', input_shape = inputs), 12 Dropout(0.25), 13 Dense(3200, activation='relu'), 14 Dropout(0.20), 15 Dense(1800, activation='relu'), 16 Dropout(0.15), 17 Dense(1024, activation='relu'), 18 Dropout(0.10), 19 Dense(512, activation='relu'), 20 Dropout(0.05), 21 Dense(256, activation='relu'), 22 Dense(128, activation='relu'), 23 Dense(64, activation='relu'), 24 Dense(32, activation='relu') 25 ]) 27 model.compile(optimizer='adam', 28 loss='mse', # Use Mean Squared Error for regression 29 metrics=['mae']) # Mean Absolute Error as an additional metric 30 return model
File c:\Users\arisa\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\models\sequential.py:73, in Sequential.init(self, layers, trainable, name) 71 if layers: 72 for layer in layers: ---> 73 self.add(layer, rebuild=False) 74 self._maybe_rebuild()
File c:\Users\arisa\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\models\sequential.py:86, in Sequential.add(self, layer, rebuild) 84 if not self._layers: 85 if getattr(layer, "_input_shape_arg", None) is not None: ---> 86 self.add(InputLayer(shape=layer._input_shape_arg)) 88 # If we are passed a Keras tensor created by keras.Input(), we 89 # extract the input layer from its keras history and use that. 90 if hasattr(layer, "_keras_history"):
File c:\Users\arisa\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\layers\core\input_layer.py:46, in InputLayer.init(self, shape, batch_size, dtype, sparse, batch_shape, input_tensor, name, **kwargs) 43 raise ValueError("You must pass a
shapeargument.") 45 if shape is not None: ---> 46 shape = backend.standardize_shape(shape) 47 batch_shape = (batch_size,) + shape 48 self.batch_shape = tuple(batch_shape)File c:\Users\arisa\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\backend\common\variables.py:510, in standardize_shape(shape) 506 if isinstance(shape, tf.TensorShape): 507 #
tf.TensorShapemay containDimensionobjects. 508 # We need to convert the items in it to either int orNone509 shape = shape.as_list() --> 510 shape = tuple(shape) 512 if config.backend() == "torch": 513 #shapemight betorch.Size. We need to convert the items in it to 514 # either int or 515 shape = tuple(map(lambda x: int(x) if x is not None else None, shape)) - Assistant
The error message you're encountering,
"NotImplementedError: Iterating over a symbolic KerasTensor is not supported.", is generally a result of trying to directly use a Keras tensor where an iterable (like a list, tuple, etc.) or a specific numerical value is expected. Based on your stack trace, the error occurs within yourbuild_modelfunction when constructing theSequentialmodel.Let's address the issue:
- User
Setup the data generator
train_generator = data_generator(file_path,batch_size)
Assuming you know or calculate the total number of rows in advance
total_samples = 1000000 # Example number, replace with your dataset's size steps_per_epoch = total_samples // batch_size
Train the model
model.fit(train_generator, steps_per_epoch=1000, epochs=10)
error: { "name": "ValueError", "message": "Dimensions must be equal, but are 12 and 32 for '{{node compile_loss/mse/sub}} = Sub[T=DT_FLOAT](compile_loss/mse/Cast, sequential_11_1/dense_107_1/Relu)' with input shapes: [?,12], [?,32].", "stack": "--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[36], line 9 6 steps_per_epoch = total_samples // batch_size 8 # Train the model ----> 9 model.fit(train_generator, steps_per_epoch=1000, epochs=10)
- Assistant
The error message you're encountering,
"ValueError: Dimensions must be equal, but are 12 and 32,"indicates a shape mismatch between your model's output and the labels provided during training. Specifically, the model is outputting tensors with a shape of , while the expected output (based on the labels from your ) is . This discrepancy prevents the mean squared error (MSE) loss calculation from proceeding since the operation requires both tensors to have the same shape. - User
{ "name": "AttributeError", "message": "'numpy.ndarray' object has no attribute 'drop'", "stack": "--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[62], line 9 6 steps_per_epoch = total_samples // batch_size 8 # Train the model ----> 9 model.fit(train_generator, steps_per_epoch=1000, epochs=10)
File c:\Users\arisa\AppData\Local\Programs\Python\Python310\lib\site-packages\keras\src\utils\traceback_utils.py:122, in filter_traceback..error_handler(*args, **kwargs) 119 filtered_tb = _process_traceback_frames(e.traceback) 120 # To get the full stack trace, call: 121 #
keras.config.disable_traceback_filtering()--> 122 raise e.with_traceback(filtered_tb) from None 123 finally: 124 del filtered_tbCell In[59], line 15, in data_generator(file_path, batch_size) 13 scaler = StandardScaler() 14 c_scaled = scaler.fit_transform(filtered_c) ---> 15 feature_data = c_scaled.drop([ 16 'y_High_1d', 'y_Low_1d', 'y_Priority_1d', 17 'y_High_2d', 'y_Low_2d', 'y_Priority_2d', 18 'y_High_3d', 'y_Low_3d', 'y_Priority_3d', 19 'y_High_5d', 'y_Low_5d', 'y_Priority_5d'], axis=1).values 20 target_data = c_scaled[['y_High_1d' 21 , 'y_Low_1d', 'y_Priority_1d', 22 'y_High_2d', 'y_Low_2d', 'y_Priority_2d', 23 'y_High_3d', 'y_Low_3d', 'y_Priority_3d', 24 'y_High_5d', 'y_Low_5d', 'y_Priority_5d' 25 ]].values 26 yield feature_data, target_data
- Assistant
- User
how could i seperate my data to train and test too?
- Assistant
- Assistant
It seems like you didn't include a specific question or topic you wanted to explore next. If you have any further inquiries or need assistance on a different topic, whether it's related to machine learning, programming in Python, data science concepts, or anything else, feel free to provide more details, and I'll be glad to help.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.