class MXNet::Gluon::NN::Dense

Overview

A densely-connected neural network layer.

Implements the operation:

output = activation(dot(input, weight) + bias)

where "activation" is the element-wise activation function passed as the activation argument, "weight" is a weights matrix created by the layer, and "bias" is a bias vector created by the layer (if argument use_bias is true).

Note: the input must be a tensor with rank two. Use flatten to convert it to rank two if necessary.

Defined in:

mxnet/gluon/nn/layers.cr

Constructors

Instance Method Summary

Instance methods inherited from class MXNet::Gluon::HybridBlock

export(filename, epoch = 0) export, forward(inputs : Array(T)) : Array(T) forall T forward, hybrid_forward(inputs : Array(T), params : Hash(String, T) = {} of String => T) : Array(T) forall T hybrid_forward, hybridize(active = true, flags = {} of String => String) hybridize, register_child(block, name = nil) register_child

Instance methods inherited from module MXNet::Gluon::CachedGraph

clear_cache clear_cache, infer_dtype(args) infer_dtype, infer_shape(args) infer_shape

Constructor methods inherited from module MXNet::Gluon::CachedGraph

new(**kwargs) new

Instance methods inherited from class MXNet::Gluon::Block

call(inputs : Array(T)) : Array(T) forall T call, children children, collect_params(selector = nil) collect_params, forward(inputs : Array(T)) : Array(T) forall T forward, get_attr(name : String) : Block | Parameter | Nil get_attr, hybridize(active = true) hybridize, init(init = nil, ctx = nil, force_reinit = false) init, load_parameters(fname, ctx = MXNet.cpu, allow_missing = false, ignore_extra = false) load_parameters, params : MXNet::Gluon::ParameterDict params, prefix : String prefix, register_child(block, name = nil) register_child, register_parameter(param, name = nil) register_parameter, save_parameters(fname) save_parameters, scope : MXNet::Gluon::BlockScope? scope, set_attr(name : String, value : Block | Parameter | Nil) set_attr, with_name_scope(&) with_name_scope

Constructor methods inherited from class MXNet::Gluon::Block

new(prefix = nil, params = nil) new

Constructor Detail

def self.new(units : Int32, in_units : Int32 = 0, use_bias = true, activation = nil, **kwargs) #

Creates a new instance.

Parameters

  • units (Int32) Dimensionality of the output space.
  • in_units (Int32, optional) Size of the input data. If nothing is specified, initialization is deferred to the first time #forward is called and in_units will be inferred from the shape of input data.
  • use_bias (Bool, default = true) Whether the layer uses a bias vector.
  • activation (String, optional) Activation function to use. If nothing is specified, no activation is applied (it acts like "linear" activation: a(x) = x).

[View source]

Instance Method Detail

def act #

[View source]
def act=(act : MXNet::Gluon::NN::Activation?) #

[View source]

[View source]
def bias #

[View source]
def bias=(bias : MXNet::Gluon::Parameter?) #

[View source]
def bias? : MXNet::Gluon::Parameter? #

[View source]
def hybrid_forward(inputs : Array(T), params : Hash(String, T)) : Array(T) forall T #
Description copied from class MXNet::Gluon::HybridBlock

Override to construct symbolic graph for this HybridBlock.

Parameters


[View source]
def weight #

[View source]
def weight=(weight : MXNet::Gluon::Parameter?) #

[View source]
def weight? : MXNet::Gluon::Parameter? #

[View source]