Image-Super-Resolution
Image-Super-Resolution copied to clipboard
Layer reshape issue
This is the input code I've Given:
X_array=np.asarray(X_train).astype(np.int)
y_array=np.asarray(y_train).astype(np.int) X_shaped = np.reshape(X_array, newshape=(-1,18727,3)) y_shaped = np.reshape(y_array,newshape=(-1,18727,2))
model = Sequential() model.add(LSTM(units=1, input_shape=(10000,3), return_sequences=True)) model.add(LSTMt_shape=(1,18727,3),dropout=0.25,return_sequences=True, input_shape=(-1,18727,2)))
model.add(LSTM(132,batch_input_shape=(1,18727,2),dropout=0.25,return_sequences=True)) model.add(Dense(1,batch_input_shape=(1,18727,3),activation='softmax',batch_size=32)) model.add(Dense(1,batch_input_shape=(1,18727,2),activation='softmax',batch_size=32))
model.compile(loss="mean_absolute_error", optimizer="adam", metrics= ['accuracy']) model.compile(loss='mse', optimizer='rmsprop',metrics=['accuracy'])## Binary cross entropy/ categorical cross start = time.time() print ('compilation time : ', time.time() - start) (units=1, input_shape=(4000,2), return_sequences=True)) model.add(LSTM(132,batch_input)
The Error im getting is this:
Epoch 1/100 WARNING:tensorflow:Model was constructed with shape (None, 10000, 3) for input KerasTensor(type_spec=TensorSpec(shape=(None, 10000, 3), dtype=tf.float32, name='lstm_16_input'), name='lstm_16_input', description="created by layer 'lstm_16_input'"), but it was called on an input with incompatible shape (None, 18727, 3). WARNING:tensorflow:Model was constructed with shape (None, 10000, 3) for input KerasTensor(type_spec=TensorSpec(shape=(None, 10000, 3), dtype=tf.float32, name='lstm_16_input'), name='lstm_16_input', description="created by layer 'lstm_16_input'"), but it was called on an input with incompatible shape (None, 18727, 3). 1/1 [==============================] - ETA: 0s - loss: 9914.3594 - accuracy: 5.3399e-04
ValueError Traceback (most recent call last)
10 frames /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs) 975 except Exception as e: # pylint:disable=broad-except 976 if hasattr(e, "ag_error_metadata"): --> 977 raise e.ag_error_metadata.to_exception(e) 978 else: 979 raise
ValueError: in user code:
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:1233 test_function *
return step_function(self, iterator)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:1224 step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:1259 run
return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica
return self._call_for_each_replica(fn, args, kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica
return fn(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:1217 run_step **
outputs = model.test_step(data)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:1183 test_step
y_pred = self(x, training=False)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/base_layer.py:998 __call__
input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/input_spec.py:223 assert_input_compatibility
str(tuple(shape)))
ValueError: Input 0 of layer sequential_3 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 3)