MeanAbsoluteLossLayer
✖
MeanAbsoluteLossLayer
represents a loss layer that computes the mean absolute loss between the "Input" port and "Target" port.
Details and Options


- MeanAbsoluteLossLayer exposes the following ports for use in NetGraph etc.:
-
"Input" an array of arbitrary rank "Target" an array of the same rank as "Input" "Loss" a real number - MeanAbsoluteLossLayer[…][<"Input" -> in, "Target"target >] explicitly computes the output from applying the layer.
- MeanAbsoluteLossLayer[…][<"Input"->{in1,in2,…},"Target"->{target1,target2,…} >] explicitly computes outputs for each of the ini and targeti.
- When given a NumericArray as input, the output will be a NumericArray.
- MeanAbsoluteLossLayer is typically used inside NetGraph to construct a training network.
- A MeanAbsoluteLossLayer[…] can be provided as the third argument to NetTrain when training a specific network.
- MeanAbsoluteLossLayer["port"->shape] allows the shape of the given input "port" to be specified. Possible forms for shape include:
-
"Real" a single real number n a vector of length n {n1,n2,…} an array of dimensions n1×n2×… "Varying" a vector whose length is variable {"Varying",n2,n3,…} an array whose first dimension is variable and whose remaining dimensions are n2×n3×… NetEncoder[…] an encoder NetEncoder[{…,"Dimensions"{n1,…}}] an encoder mapped over an array of dimensions n1×… - Options[MeanAbsoluteLossLayer] gives the list of default options to construct the layer. Options[MeanAbsoluteLossLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[MeanAbsoluteLossLayer[…]] gives a report about the layer.
- Information[MeanAbsoluteLossLayer[…],prop] gives the value of the property prop of MeanAbsoluteLossLayer[…]. Possible properties are the same as for NetGraph.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Create a MeanAbsoluteLossLayer layer:

https://wolfram.com/xid/0yj2be51zi33znaduq-9reqx3

Create a MeanAbsoluteLossLayer that takes length-3 vectors:

https://wolfram.com/xid/0yj2be51zi33znaduq-cfiivd


https://wolfram.com/xid/0yj2be51zi33znaduq-0n9a3o

Create a NetGraph containing a MeanAbsoluteLossLayer:

https://wolfram.com/xid/0yj2be51zi33znaduq-39v8wd


https://wolfram.com/xid/0yj2be51zi33znaduq-3g473h

Scope (4)Survey of the scope of standard use cases
Arguments (1)
Create a MeanAbsoluteLossLayer:

https://wolfram.com/xid/0yj2be51zi33znaduq-437fy3

Apply the MeanAbsoluteLossLayer to a pair of matrices:

https://wolfram.com/xid/0yj2be51zi33znaduq-xfv3o2

Apply the MeanAbsoluteLossLayer to a pair of vectors:

https://wolfram.com/xid/0yj2be51zi33znaduq-hxlt7u

Apply the MeanAbsoluteLossLayer to a pair of numbers:

https://wolfram.com/xid/0yj2be51zi33znaduq-ytsn5g

Ports (3)
Create a MeanAbsoluteLossLayer that assumes the input data are vectors of length 2:

https://wolfram.com/xid/0yj2be51zi33znaduq-rowe7w

Thread the layer across a batch of inputs:

https://wolfram.com/xid/0yj2be51zi33znaduq-fojtxu

Create a MeanAbsoluteLossLayer that takes two variable-length vectors:

https://wolfram.com/xid/0yj2be51zi33znaduq-1w1d3n

Apply the layer to an input and target vector:

https://wolfram.com/xid/0yj2be51zi33znaduq-x3ytxw

Thread the layer over a batch of input and target vectors:

https://wolfram.com/xid/0yj2be51zi33znaduq-uu191j

Create a MeanAbsoluteLossLayer that takes two images as input:

https://wolfram.com/xid/0yj2be51zi33znaduq-bq1zo4

Apply the layer to two dissimilar images:

https://wolfram.com/xid/0yj2be51zi33znaduq-us5jzd

Apply the layer to two dissimilar images:

https://wolfram.com/xid/0yj2be51zi33znaduq-wx7xun

Applications (1)Sample problems that can be solved with this function
Define a single-layer neural network that takes in scalar numeric values and produces scalar numeric values, and train this network using a MeanAbsoluteLossLayer:

https://wolfram.com/xid/0yj2be51zi33znaduq-js14pr

Predict the value of a new input:

https://wolfram.com/xid/0yj2be51zi33znaduq-zb55y9

Properties & Relations (2)Properties of the function, and connections to other functions
MeanAbsoluteLossLayer computes:

https://wolfram.com/xid/0yj2be51zi33znaduq-tqmrp1
Compare the output of the layer and the definition on an example:

https://wolfram.com/xid/0yj2be51zi33znaduq-cfaack


MeanAbsoluteLossLayer effectively computes a normalized version of ManhattanDistance:

https://wolfram.com/xid/0yj2be51zi33znaduq-xjq9ix


https://wolfram.com/xid/0yj2be51zi33znaduq-g85zq2

Wolfram Research (2016), MeanAbsoluteLossLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html (updated 2019).
Text
Wolfram Research (2016), MeanAbsoluteLossLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html (updated 2019).
Wolfram Research (2016), MeanAbsoluteLossLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html (updated 2019).
CMS
Wolfram Language. 2016. "MeanAbsoluteLossLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html.
Wolfram Language. 2016. "MeanAbsoluteLossLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html.
APA
Wolfram Language. (2016). MeanAbsoluteLossLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html
Wolfram Language. (2016). MeanAbsoluteLossLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html
BibTeX
@misc{reference.wolfram_2025_meanabsolutelosslayer, author="Wolfram Research", title="{MeanAbsoluteLossLayer}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html}", note=[Accessed: 22-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_meanabsolutelosslayer, organization={Wolfram Research}, title={MeanAbsoluteLossLayer}, year={2019}, url={https://reference.wolfram.com/language/ref/MeanAbsoluteLossLayer.html}, note=[Accessed: 22-April-2025
]}