Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -81,7 +81,19 @@ class Plasticity:
|
|
| 81 |
|
| 82 |
# Применяем адаптацию к ИСХОДНОЙ матрице
|
| 83 |
with torch.no_grad():
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
if weight_matrix.dim() == 3:
|
| 86 |
update = update.reshape(original_shape)
|
| 87 |
weight_matrix = weight_matrix + update
|
|
|
|
| 81 |
|
| 82 |
# Применяем адаптацию к ИСХОДНОЙ матрице
|
| 83 |
with torch.no_grad():
|
| 84 |
+
# БЕРЁМ СРЕЗ ОТ self.w
|
| 85 |
+
update_slice = self.w[:wm_2d.shape[0], :wm_2d.shape[1]]
|
| 86 |
+
|
| 87 |
+
# ЕСЛИ СРЕЗ МЕНЬШЕ, ЧЕМ НУЖНО, ПОВТОРЯЕМ ЕГО
|
| 88 |
+
if update_slice.shape[0] < wm_2d.shape[0] or update_slice.shape[1] < wm_2d.shape[1]:
|
| 89 |
+
repeat_rows = (wm_2d.shape[0] + update_slice.shape[0] - 1) // update_slice.shape[0]
|
| 90 |
+
repeat_cols = (wm_2d.shape[1] + update_slice.shape[1] - 1) // update_slice.shape[1]
|
| 91 |
+
update = update_slice.repeat(repeat_rows, repeat_cols)[:wm_2d.shape[0], :wm_2d.shape[1]]
|
| 92 |
+
else:
|
| 93 |
+
update = update_slice
|
| 94 |
+
|
| 95 |
+
update = update * 0.01
|
| 96 |
+
|
| 97 |
if weight_matrix.dim() == 3:
|
| 98 |
update = update.reshape(original_shape)
|
| 99 |
weight_matrix = weight_matrix + update
|