pub struct NatureDqnQNetwork<B: Backend> { /* private fields */ }Expand description
Nature-DQN-scale Q-network CNN on Burn.
Same conv trunk as NatureDqnBurnPolicy, but with a single q_head
whose outputs are interpreted directly as Q(s, a) (no softmax). Includes
a record-based copy_params_from for target-net sync, mirroring
crate::policy::q_network::QNetworkBurn.
Implementations§
Source§impl<B: Backend> NatureDqnQNetwork<B>
impl<B: Backend> NatureDqnQNetwork<B>
Sourcepub fn new(n_actions: usize, device: &B::Device) -> Self
pub fn new(n_actions: usize, device: &B::Device) -> Self
Construct a fresh Q-network with unseeded (Burn-default) init.
Sourcepub fn with_config(
n_actions: usize,
config: NatureDqnConfig,
device: &B::Device,
) -> Self
pub fn with_config( n_actions: usize, config: NatureDqnConfig, device: &B::Device, ) -> Self
Construct a fresh Q-network with the given configuration.
When config.seed is Some, the two FC layers (0 = fc_common,
1 = q_head) are built from deterministically-derived host-side RNG
streams. Conv layers are always unseeded.
Sourcepub fn forward(&self, obs: Tensor<B, 4>) -> Tensor<B, 2>
pub fn forward(&self, obs: Tensor<B, 4>) -> Tensor<B, 2>
Forward pass: compute Q(s, a) for every action a.
obsshape[batch, 4, 84, 84](NCHW, pixels in0.0..=1.0).- Returns Q-values of shape
[batch, n_actions].
Sourcepub fn copy_params_from(
self,
source: &NatureDqnQNetwork<B>,
) -> NatureDqnQNetwork<B>
pub fn copy_params_from( self, source: &NatureDqnQNetwork<B>, ) -> NatureDqnQNetwork<B>
Replace this network’s parameters with a deep copy of source’s
parameters (target-net sync). Returns a new module, mirroring
crate::policy::q_network::QNetworkBurn::copy_params_from.
Trait Implementations§
Source§impl<B> AutodiffModule<B> for NatureDqnQNetwork<B>
impl<B> AutodiffModule<B> for NatureDqnQNetwork<B>
Source§type InnerModule = NatureDqnQNetwork<<B as AutodiffBackend>::InnerBackend>
type InnerModule = NatureDqnQNetwork<<B as AutodiffBackend>::InnerBackend>
Source§fn valid(&self) -> Self::InnerModule
fn valid(&self) -> Self::InnerModule
Source§fn from_inner(module: Self::InnerModule) -> Self
fn from_inner(module: Self::InnerModule) -> Self
Source§impl<B: Backend> Clone for NatureDqnQNetwork<B>
impl<B: Backend> Clone for NatureDqnQNetwork<B>
Source§impl<B: Backend> Display for NatureDqnQNetwork<B>
impl<B: Backend> Display for NatureDqnQNetwork<B>
Source§impl<B> HasAutodiffModule<B> for NatureDqnQNetwork<B::InnerBackend>
impl<B> HasAutodiffModule<B> for NatureDqnQNetwork<B::InnerBackend>
Source§type TrainModule = NatureDqnQNetwork<B>
type TrainModule = NatureDqnQNetwork<B>
Source§impl<B: Backend> Module<B> for NatureDqnQNetwork<B>
impl<B: Backend> Module<B> for NatureDqnQNetwork<B>
Source§type Record = NatureDqnQNetworkRecord<B>
type Record = NatureDqnQNetworkRecord<B>
Source§fn load_record(self, record: Self::Record) -> Self
fn load_record(self, record: Self::Record) -> Self
Source§fn into_record(self) -> Self::Record
fn into_record(self) -> Self::Record
Source§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Source§fn visit<Visitor: ModuleVisitor<B>>(&self, visitor: &mut Visitor)
fn visit<Visitor: ModuleVisitor<B>>(&self, visitor: &mut Visitor)
Source§fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self
fn map<Mapper: ModuleMapper<B>>(self, mapper: &mut Mapper) -> Self
Source§fn collect_devices(&self, devices: Devices<B>) -> Devices<B>
fn collect_devices(&self, devices: Devices<B>) -> Devices<B>
Source§fn to_device(self, device: &B::Device) -> Self
fn to_device(self, device: &B::Device) -> Self
Source§fn fork(self, device: &B::Device) -> Self
fn fork(self, device: &B::Device) -> Self
Source§fn devices(&self) -> Vec<<B as BackendTypes>::Device>
fn devices(&self) -> Vec<<B as BackendTypes>::Device>
Source§fn train<AB>(self) -> Self::TrainModulewhere
AB: AutodiffBackend<InnerBackend = B>,
Self: HasAutodiffModule<AB>,
fn train<AB>(self) -> Self::TrainModulewhere
AB: AutodiffBackend<InnerBackend = B>,
Self: HasAutodiffModule<AB>,
Source§fn save_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
) -> Result<(), RecorderError>
fn save_file<FR, PB>( self, file_path: PB, recorder: &FR, ) -> Result<(), RecorderError>
Source§fn load_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
device: &<B as BackendTypes>::Device,
) -> Result<Self, RecorderError>
fn load_file<FR, PB>( self, file_path: PB, recorder: &FR, device: &<B as BackendTypes>::Device, ) -> Result<Self, RecorderError>
Source§fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
Source§impl<B: Backend> ModuleDisplay for NatureDqnQNetwork<B>
impl<B: Backend> ModuleDisplay for NatureDqnQNetwork<B>
Source§fn format(&self, passed_settings: DisplaySettings) -> String
fn format(&self, passed_settings: DisplaySettings) -> String
Source§fn custom_settings(&self) -> Option<DisplaySettings>
fn custom_settings(&self) -> Option<DisplaySettings>
Auto Trait Implementations§
impl<B> !Freeze for NatureDqnQNetwork<B>
impl<B> !RefUnwindSafe for NatureDqnQNetwork<B>
impl<B> !UnwindSafe for NatureDqnQNetwork<B>
impl<B> Send for NatureDqnQNetwork<B>
impl<B> Sync for NatureDqnQNetwork<B>
impl<B> Unpin for NatureDqnQNetwork<B>where
<B as BackendTypes>::FloatTensorPrimitive: Unpin,
<B as BackendTypes>::QuantizedTensorPrimitive: Unpin,
<B as BackendTypes>::Device: Unpin,
impl<B> UnsafeUnpin for NatureDqnQNetwork<B>where
<B as BackendTypes>::Device: UnsafeUnpin,
<B as BackendTypes>::FloatTensorPrimitive: UnsafeUnpin,
<B as BackendTypes>::QuantizedTensorPrimitive: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more