Commit ea5cd09
committed
Fix: Remove deprecated .path access in Muon optimizer for TF 2.16+ compatibility
Fixes keras.optimizers.Muon failing with AttributeError: 'ResourceVariable' object has no attribute 'path' in Keras 3 / TF 2.16-2.20.
Changes:
- Replaced deprecated .path references with _get_variable_index() for variable identification
- Updated build() to use lists instead of dicts, initialized with [None] * len(var_list)
- Updated _should_use_adamw() logic to safely check .path only during build
- Updated update_step(), _muon_update_step(), and _adamw_update_step() to use _get_variable_index()
- Added robust error handling for invalid regex patterns in exclude_layers
- Reverted image_utils.py changes as requested by reviewer
Result: All tests pass. Compatible with TensorFlow 2.16+.
Closes #217931 parent 198512f commit ea5cd09
2 files changed
+30
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
138 | 142 | | |
139 | | - | |
140 | | - | |
141 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
147 | | - | |
148 | | - | |
| 156 | + | |
| 157 | + | |
149 | 158 | | |
150 | 159 | | |
151 | | - | |
| 160 | + | |
152 | 161 | | |
153 | 162 | | |
154 | 163 | | |
155 | 164 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
164 | | - | |
| 171 | + | |
| 172 | + | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
168 | 176 | | |
169 | 177 | | |
170 | | - | |
| 178 | + | |
171 | 179 | | |
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
176 | 184 | | |
177 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
178 | 188 | | |
179 | 189 | | |
180 | 190 | | |
| |||
183 | 193 | | |
184 | 194 | | |
185 | 195 | | |
186 | | - | |
| 196 | + | |
| 197 | + | |
187 | 198 | | |
188 | 199 | | |
189 | 200 | | |
| |||
210 | 221 | | |
211 | 222 | | |
212 | 223 | | |
213 | | - | |
214 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
215 | 227 | | |
216 | 228 | | |
217 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | 183 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | 184 | | |
197 | 185 | | |
198 | 186 | | |
| |||
464 | 452 | | |
465 | 453 | | |
466 | 454 | | |
467 | | - | |
468 | | - | |
469 | 455 | | |
0 commit comments