MnistModel#

class MnistModel[source]#

Represent a simple MNIST network.

__init__()[source]#

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

__new__(*args, **kwargs)#

Attributes

MnistModel.dump_patches

This allows better BC support for load_state_dict().

Methods

MnistModel.add_module(name, module)

Adds a child module to the current module.

MnistModel.apply(fn)

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

MnistModel.bfloat16()

Casts all floating point parameters and buffers to bfloat16 datatype.

MnistModel.buffers([recurse])

Returns an iterator over module buffers.

MnistModel.children()

Returns an iterator over immediate children modules.

MnistModel.cpu()

Moves all model parameters and buffers to the CPU.

MnistModel.cuda([device])

Moves all model parameters and buffers to the GPU.

MnistModel.double()

Casts all floating point parameters and buffers to double datatype.

MnistModel.eval()

Sets the module in evaluation mode.

MnistModel.extra_repr()

Set the extra representation of the module

MnistModel.float()

Casts all floating point parameters and buffers to float datatype.

MnistModel.forward(x)

Run a forward step on the network.

MnistModel.get_buffer(target)

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

MnistModel.get_extra_state()

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

MnistModel.get_parameter(target)

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

MnistModel.get_submodule(target)

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

MnistModel.half()

Casts all floating point parameters and buffers to half datatype.

MnistModel.load_state_dict(state_dict[, strict])

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

MnistModel.modules()

Returns an iterator over all modules in the network.

MnistModel.named_buffers([prefix, recurse])

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

MnistModel.named_children()

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

MnistModel.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.

MnistModel.named_parameters([prefix, recurse])

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

MnistModel.parameters([recurse])

Returns an iterator over module parameters.

MnistModel.register_backward_hook(hook)

Registers a backward hook on the module.

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

Adds a buffer to the module.

MnistModel.register_forward_hook(hook)

Registers a forward hook on the module.

MnistModel.register_forward_pre_hook(hook)

Registers a forward pre-hook on the module.

MnistModel.register_full_backward_hook(hook)

Registers a backward hook on the module.

MnistModel.register_parameter(name, param)

Adds a parameter to the module.

MnistModel.requires_grad_([requires_grad])

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

MnistModel.set_extra_state(state)

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

MnistModel.share_memory()

See torch.Tensor.share_memory_()

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

Returns a dictionary containing a whole state of the module.

MnistModel.to(*args, **kwargs)

Moves and/or casts the parameters and buffers.

MnistModel.to_empty(*, device)

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

MnistModel.train([mode])

Sets the module in training mode.

MnistModel.type(dst_type)

Casts all parameters and buffers to dst_type.

MnistModel.xpu([device])

Moves all model parameters and buffers to the XPU.

MnistModel.zero_grad([set_to_none])

Sets gradients of all model parameters to zero.