Это также происходит с примерами фотографий, которые прилагаются к пакету, поэтому это очень странно. что оно не работает так, как должно. Кто-нибудь знает, как это исправить, не меняя код пакета?
Код: Выделить всё
from sam_lstm import SalMap
import os
if not os.path.exists("\\samples"):
os.makedirs("\\samples")
SalMap.auto()
Код: Выделить всё
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [5], in ()
6 if not os.path.exists("\\samples"):
7 os.makedirs("\\samples")
----> 9 SalMap.auto()
File ~\anaconda3\lib\site-packages\sam_lstm\__init__.py:48, in SalMap.auto(cls)
45 @classmethod
46 def auto(cls):
47 salmap = cls()
---> 48 salmap.compile()
49 salmap.load_weights()
50 salmap.predict_maps()
File ~\anaconda3\lib\site-packages\sam_lstm\__init__.py:59, in SalMap.compile(self)
57 def compile(self):
58 self.model = Model(
---> 59 inputs=[self.x, self.x_maps], outputs=sam_resnet([self.x, self.x_maps])
60 )
61 self.model.compile(
62 RMSprop(learning_rate=1e-4),
63 loss=[kl_divergence, correlation_coefficient, nss],
64 loss_weights=[10, -2, -1],
65 )
File ~\anaconda3\lib\site-packages\sam_lstm\models.py:192, in sam_resnet(x)
190 def sam_resnet(x):
191 # Dilated Convolutional Network
--> 192 dcn = dcn_resnet(input_tensor=x[0])
193 conv_feat = Conv2D(512, (3, 3), padding="same", activation="relu")(dcn.output)
194 # Attentive Convolutional LSTM
File ~\anaconda3\lib\site-packages\sam_lstm\dcn_resnet.py:259, in dcn_resnet(input_tensor)
252 # Load weights
253 weights_path = get_file(
254 "resnet50_weights_th_dim_ordering_th_kernels_notop.h5",
255 TH_WEIGHTS_PATH_NO_TOP,
256 cache_subdir="weights",
257 file_hash="f64f049c92468c9affcd44b0976cdafe",
258 )
--> 259 model.load_weights(weights_path)
261 return model
File ~\anaconda3\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_tb
File ~\anaconda3\lib\site-packages\keras\src\backend\common\variables.py:226, in KerasVariable.assign(self, value)
224 value = self._convert_to_tensor(value, dtype=self.dtype)
225 if not shape_equal(value.shape, self.shape):
--> 226 raise ValueError(
227 "The shape of the target variable and "
228 "the shape of the target value in "
229 "`variable.assign(value)` must match. "
230 f"variable.shape={self.value.shape}, "
231 f"Received: value.shape={value.shape}. "
232 f"Target variable: {self}"
233 )
234 if in_stateless_scope():
235 scope = get_stateless_scope()
ValueError: The shape of the target variable and the shape of the target value in `variable.assign(value)` must match. variable.shape=(7, 7, 3, 64), Received: value.shape=(64, 3, 7, 7). Target variable:
Подробнее здесь: https://stackoverflow.com/questions/786 ... stm-resnet