Class: Gsplat::Strategy::MCMC
Overview
3D Gaussian Splatting as Markov Chain Monte Carlo strategy.
Constant Summary collapse
- DEFAULTS =
Upstream-compatible relocation and noise defaults.
{ cap_max: 1_000_000, noise_lr: 5e5, refine_start_iter: 500, refine_stop_iter: 25_000, refine_every: 100, min_opacity: 0.005, verbose: false }.freeze
Constants inherited from Base
Instance Attribute Summary collapse
-
#cap_max ⇒ Object
readonly
Returns the value of attribute cap_max.
-
#min_opacity ⇒ Object
readonly
Returns the value of attribute min_opacity.
-
#noise_lr ⇒ Object
readonly
Returns the value of attribute noise_lr.
-
#refine_every ⇒ Object
readonly
Returns the value of attribute refine_every.
-
#refine_start_iter ⇒ Object
readonly
Returns the value of attribute refine_start_iter.
-
#refine_stop_iter ⇒ Object
readonly
Returns the value of attribute refine_stop_iter.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(**options) ⇒ MCMC
constructor
A new instance of MCMC.
-
#initialize_state(scene_scale: 1.0) ⇒ Hash
Creates strategy state including the relocation binomial table.
-
#step_post_backward(params:, optimizers:, state:, step:, info:, **options) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Methods inherited from Base
#check_sanity, #step_pre_backward
Constructor Details
#initialize(**options) ⇒ MCMC
Returns a new instance of MCMC.
21 22 23 24 25 26 27 28 |
# File 'lib/gsplat/strategy/mcmc.rb', line 21 def initialize(**) super() unknown = .keys - DEFAULTS.keys raise ArgumentError, "unknown options: #{unknown.join(', ')}" unless unknown.empty? DEFAULTS.merge().each { |name, value| instance_variable_set(:"@#{name}", value) } end |
Instance Attribute Details
#cap_max ⇒ Object (readonly)
Returns the value of attribute cap_max.
18 19 20 |
# File 'lib/gsplat/strategy/mcmc.rb', line 18 def cap_max @cap_max end |
#min_opacity ⇒ Object (readonly)
Returns the value of attribute min_opacity.
18 19 20 |
# File 'lib/gsplat/strategy/mcmc.rb', line 18 def min_opacity @min_opacity end |
#noise_lr ⇒ Object (readonly)
Returns the value of attribute noise_lr.
18 19 20 |
# File 'lib/gsplat/strategy/mcmc.rb', line 18 def noise_lr @noise_lr end |
#refine_every ⇒ Object (readonly)
Returns the value of attribute refine_every.
18 19 20 |
# File 'lib/gsplat/strategy/mcmc.rb', line 18 def refine_every @refine_every end |
#refine_start_iter ⇒ Object (readonly)
Returns the value of attribute refine_start_iter.
18 19 20 |
# File 'lib/gsplat/strategy/mcmc.rb', line 18 def refine_start_iter @refine_start_iter end |
#refine_stop_iter ⇒ Object (readonly)
Returns the value of attribute refine_stop_iter.
18 19 20 |
# File 'lib/gsplat/strategy/mcmc.rb', line 18 def refine_stop_iter @refine_stop_iter end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
18 19 20 |
# File 'lib/gsplat/strategy/mcmc.rb', line 18 def verbose @verbose end |
Instance Method Details
#initialize_state(scene_scale: 1.0) ⇒ Hash
Creates strategy state including the relocation binomial table.
34 35 36 |
# File 'lib/gsplat/strategy/mcmc.rb', line 34 def initialize_state(scene_scale: 1.0) super.merge(binoms: Gsplat::Ops::Relocation.binomial_table(n_max: 51)) end |
#step_post_backward(params:, optimizers:, state:, step:, info:, **options) ⇒ Object
rubocop:disable Metrics/ParameterLists
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gsplat/strategy/mcmc.rb', line 39 def step_post_backward(params:, optimizers:, state:, step:, info:, **) raise ArgumentError, "info must be a Hash" unless info.is_a?(Hash) learning_rate = .fetch(:lr) check_sanity(params, optimizers) if should_refine?(step) relocated = relocate_dead!(params, optimizers, state) added = add_new!(params, optimizers, state) log_step(step, relocated, added) if verbose end Ops.inject_position_noise!(params, scaler: learning_rate * noise_lr) state end |