You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# if we failed to find valid initial parameters, error
166
+
returnerror(
167
+
"failed to find valid initial parameters in $(max_attempts) tries. This may indicate an error with the model or AD backend; please open an issue at https://github.com/TuringLang/Turing.jl/issues",
168
+
)
169
+
end
170
+
141
171
function DynamicPPL.initialstep(
142
172
rng::AbstractRNG,
143
173
model::AbstractModel,
@@ -170,33 +200,14 @@ function DynamicPPL.initialstep(
# If no initial parameters are provided, resample until the log probability
177
-
# and its gradient are finite.
178
-
if initial_params ===nothing
179
-
init_attempt_count =1
180
-
while!isfinite(z)
181
-
if init_attempt_count ==10
182
-
@warn"failed to find valid initial parameters in $(init_attempt_count) tries; consider providing explicit initial parameters using the `initial_params` keyword"
183
-
end
184
-
if init_attempt_count ==1000
185
-
error(
186
-
"failed to find valid initial parameters in $(init_attempt_count) tries. This may indicate an error with the model or AD backend; please open an issue at https://github.com/TuringLang/Turing.jl/issues",
187
-
)
188
-
end
189
-
190
-
# NOTE: This will sample in the unconstrained space.
191
-
vi =last(DynamicPPL.evaluate!!(model, rng, vi, SampleFromUniform()))
0 commit comments