MNistNet#

class MNistNet[source]#

Represent a simple MNIST network.

__init__()[source]#

Initializes internal Module state, shared by both nn.Module and ScriptModule.

__new__(*args, **kwargs)#

Attributes

MNistNet.dump_patches

This allows better BC support for load_state_dict().

Methods

MNistNet.add_module(name, module)

Adds a child module to the current module.

MNistNet.apply(fn)

Applies fn recursively to every submodule (as returned by .children()) as well as self.

MNistNet.bfloat16()

Casts all floating point parameters and buffers to bfloat16 datatype.

MNistNet.buffers([recurse])

Returns an iterator over module buffers.

MNistNet.children()

Returns an iterator over immediate children modules.

MNistNet.cpu()

Moves all model parameters and buffers to the CPU.

MNistNet.cuda([device])

Moves all model parameters and buffers to the GPU.

MNistNet.double()

Casts all floating point parameters and buffers to double datatype.

MNistNet.eval()

Sets the module in evaluation mode.

MNistNet.extra_repr()

Set the extra representation of the module

MNistNet.float()

Casts all floating point parameters and buffers to float datatype.

MNistNet.forward(x)

Run a forward step on the network.

MNistNet.get_buffer(target)

Returns the buffer given by target if it exists, otherwise throws an error.

MNistNet.get_extra_state()

Returns any extra state to include in the module's state_dict.

MNistNet.get_parameter(target)

Returns the parameter given by target if it exists, otherwise throws an error.

MNistNet.get_submodule(target)

Returns the submodule given by target if it exists, otherwise throws an error.

MNistNet.half()

Casts all floating point parameters and buffers to half datatype.

MNistNet.load_state_dict(state_dict[, strict])

Copies parameters and buffers from state_dict into this module and its descendants.

MNistNet.modules()

Returns an iterator over all modules in the network.

MNistNet.named_buffers([prefix, recurse])

Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.

MNistNet.named_children()

Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself.

MNistNet.named_modules([memo, prefix, ...])

Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.

MNistNet.named_parameters([prefix, recurse])

Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.

MNistNet.parameters([recurse])

Returns an iterator over module parameters.

MNistNet.register_backward_hook(hook)

Registers a backward hook on the module.

MNistNet.register_buffer(name, tensor[, ...])

Adds a buffer to the module.

MNistNet.register_forward_hook(hook)

Registers a forward hook on the module.

MNistNet.register_forward_pre_hook(hook)

Registers a forward pre-hook on the module.

MNistNet.register_full_backward_hook(hook)

Registers a backward hook on the module.

MNistNet.register_parameter(name, param)

Adds a parameter to the module.

MNistNet.requires_grad_([requires_grad])

Change if autograd should record operations on parameters in this module.

MNistNet.set_extra_state(state)

This function is called from load_state_dict() to handle any extra state found within the state_dict.

MNistNet.share_memory()

See torch.Tensor.share_memory_()

MNistNet.state_dict([destination, prefix, ...])

Returns a dictionary containing a whole state of the module.

MNistNet.to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

MNistNet.to_empty(*, device)

Moves the parameters and buffers to the specified device without copying storage.

MNistNet.train([mode])

Sets the module in training mode.

MNistNet.type(dst_type)

Casts all parameters and buffers to dst_type.

MNistNet.xpu([device])

Moves all model parameters and buffers to the XPU.

MNistNet.zero_grad([set_to_none])

Sets gradients of all model parameters to zero.