File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
pytorch_lightning/utilities Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -131,20 +131,20 @@ def apply_to_collection(
131
131
result = deepcopy (data , memo = memo )
132
132
# apply function to each field
133
133
for field_name , (field_value , field_init ) in fields .items ():
134
- if field_init :
135
- v = apply_to_collection (
136
- field_value ,
137
- dtype ,
138
- function ,
139
- * args ,
140
- wrong_dtype = wrong_dtype ,
141
- include_none = include_none ,
142
- ** kwargs ,
143
- )
144
- if include_none or v is not None :
145
- setattr ( result , field_name , v )
146
- else : # retain old value
147
- setattr (result , field_name , getattr ( data , field_name ) )
134
+ if not field_init :
135
+ continue
136
+ v = apply_to_collection (
137
+ field_value ,
138
+ dtype ,
139
+ function ,
140
+ * args ,
141
+ wrong_dtype = wrong_dtype ,
142
+ include_none = include_none ,
143
+ ** kwargs ,
144
+ )
145
+ if not include_none and v is None : # retain old value
146
+ v = getattr ( data , field_name )
147
+ setattr (result , field_name , v )
148
148
return result
149
149
150
150
# data is neither of dtype, nor a collection
You can’t perform that action at this time.
0 commit comments