Unet network using the neural network tools

Hi
I created the following unet network using the neural network tools:

UNET := NetGraph[
  <|
   "enc_1" -> conv[64],
   "enc_2" -> {pool, conv[128]},
   "enc_3" -> {pool, conv[256]},
   "enc_4" -> {pool, conv[512]},
   "enc_5" -> {pool, conv[10]},
   "dec_1" -> dec[512],
   "dec_2" -> dec[256],
   "dec_3" -> dec[128],
   "dec_4" -> dec[64],
   "map" -> {ConvolutionLayer[1, {1, 1}], LogisticSigmoid}
   |>,
  {
   NetPort["Input"] -> 
    "enc_1" -> "enc_2" -> "enc_3" -> "enc_4" -> "enc_5",
   {"enc_4", "enc_5"} -> "dec_1",
   {"enc_3", "dec_1"} -> "dec_2",
   {"enc_2", "dec_2"} -> "dec_3",
   {"enc_1", "dec_3"} -> "dec_4",
   "dec_4" -> "map" -> NetPort["Output"]},
  "Input" -> 
   NetEncoder[{"Image", {512, 1}, ColorSpace -> "Grayscale"}], 
  "Output\[Rule] NetDecoder[{" Image "," Grayscale "}]
   ]

How can I get the output of the “enc5” layer ?

This can be done by connecting an output port to that layer. Example.

Thank you.
In accordance to the first example in your link, I added in the NetGraph

"enc_5" -> NetPort["layer5"]

Then, I tried to run it with the same command in the example:

nNetInfo =  NetTrain[net, trainingData,  "Output" -> CrossEntropyLossLayer["Index"]]

But I got error massages:

OptionValue::nodef "Unknown option \!\(\"Output\"\) for NetTrain"
NetTrain::missinslot "Specification for slot \!\(\"layer5\"\) is missing."

and in the NetTrain function command “Output” and “index” are colored by red.

What am I doing wrong ?

Thanks

Any ideas please ? 1. How can I get the Output of layer “enc5” ?

NetTrain[
unet,
<|
“Input” → images,
“Output” → masks
|>,
LossFunction → {“Output” → CrossEntropyLossLayer[“Binary”]}
]