NetExtract[layer,"param"]
指定されたネット層についてのパラメータの値を取り出す.
NetExtract[net,lspec]
lspec で特定された層を,net 中のNetGraphオブジェクトあるいはNetChainオブジェクトの中から取り出す.
NetExtract[net,{lspec,"param"}]
パラメータ param の値を net 中の lspec で特定された層から取り出す.
NetExtract[net,NetArray[spec]]
ネットワークあるいは層の中の共有配列の値を抽出する.
NetExtract[coder,"param"]
指定されたNetEncoderあるいはNetDecoderのパラメータの値を抽出する.
NetExtract[…,{spec1,spec2,…}]
各 speciがリストである要素の集合を抽出する.
NetExtract[spec]
式に適用可能なNetExtractの演算子形を表す.
NetExtract
NetExtract[layer,"param"]
指定されたネット層についてのパラメータの値を取り出す.
NetExtract[net,lspec]
lspec で特定された層を,net 中のNetGraphオブジェクトあるいはNetChainオブジェクトの中から取り出す.
NetExtract[net,{lspec,"param"}]
パラメータ param の値を net 中の lspec で特定された層から取り出す.
NetExtract[net,NetArray[spec]]
ネットワークあるいは層の中の共有配列の値を抽出する.
NetExtract[coder,"param"]
指定されたNetEncoderあるいはNetDecoderのパラメータの値を抽出する.
NetExtract[…,{spec1,spec2,…}]
各 speciがリストである要素の集合を抽出する.
NetExtract[spec]
式に適用可能なNetExtractの演算子形を表す.
詳細
- NetExtractは,NetGraphあるいはNetChain内のすべてのネット層,ネット層の全特性,あるいはNetEncoderおよびNetDecoderが与えられたときに連想が返されるべきであることを示すレベル指定Allをサポートする.
- 層指定は,n 番目の層を示す整数か名前付きの層を示す文字列でよい.
- パラメータ指定は任意の配列の名前または層に含まれるオプションの名前でよい.
- NetExtractは,学習されたパラメータがまだ初期化されていない,あるいは学習していないパラメータがまだ参照されていない場合はAutomaticを返す.
- NetExtract[net,{spec1,spec2,…}]は,speciがリストではない場合は net[[spec1,spec2,…]]に等しい.
- NetChain,NetGraph,NetEncoder,NetDecoderおよび層については,Normal[net]はNetExtract[net,All]と等価である.
例題
すべて開く すべて閉じる例 (4)
layer = NetInitialize @ LinearLayer[2, "Input" -> 2]NetExtract[layer, "Weights"]//NormalNetChainを作る:
chain = NetChain[{1, 2, 3}]NetExtract[chain, 3]op = NetMapOperator[LinearLayer[5]]NetExtract[op, "Net"]NetEncoderを作成する:
encoder = NetEncoder["Image"]NetExtract[encoder, "Type"]NetExtract[encoder, "Output"]NetExtract[encoder, "ColorSpace"]スコープ (7)
名前付きの層でNetChainを作る:
chain = NetChain[<|"x" -> LinearLayer[5], "y" -> Ramp, "z" -> LinearLayer[10]|>]NetExtract[chain, 1]NetExtract[chain, -1]NetExtract[chain, "y"]NetExtract[chain, {2, "Function"}]NetExtract[chain, {{1}, {3}}]NetExtract[chain, All]初期化されたNetChainを作る:
chain = NetInitialize @ NetChain[<|"a" -> 2, "b" -> 2, "c" -> 2|>, "Input" -> 2]NetExtract[chain, {2, "Weights"}]NetExtract[chain, {All, "Weights"}]名前付きの層のあるNetGraphオブジェクトを作る:
graph = NetGraph[<|"linear1" -> LinearLayer[2], "linear2" -> LinearLayer[5]|>, {"linear1" -> "linear2"}]NetExtract[graph, "linear1"]NetExtract[graph, All]net = FlattenLayer["Input" -> {5, 5}]NetExtract[net, "Input"]NetExtract[net, "Output"]net = PoolingLayer[5, "Input" -> NetEncoder["Image"]]NetExtract[net, "Input"]NetExtract[net, {"Input", "ImageSize"}]NetExtract[net, {"Input", {"Type", "Output"}}]net = NetInitialize[NetChain[{NetInsertSharedArrays[EmbeddingLayer[3]], NetInsertSharedArrays[LinearLayer[2]]}]]NetExtract[net, NetArray[All]]NetExtract[net, NetArray["Weights"]]この例では,NetArray["Weights"]はすべての層の重みの値に相当する:
NetExtract[net, {All, "Weights"}]NetExtract演算子を使う:
NetExtract[1]@NetChain[{ElementwiseLayer[Sin], SummationLayer[]}]特性と関係 (1)
NetExtractがサポートする部分指定はNetReplacePartが使うものと同じである.NetChainの第3層の重みを抽出する:
partSpec = {3, "Weights"};net = NetInitialize@NetChain[{LinearLayer[2], Ramp, LinearLayer[3], Ramp}, "Input" -> {3}];NetExtract[net, partSpec]NetReplacePart[net, partSpec -> {{1, 2}, {3, 4}, {5, 6}}]考えられる問題 (1)
ConvolutionLayerを作る:
conv = ConvolutionLayer[3, {2, 2}]この初期化されていない層の重みを取り出そうとするとAutomaticが返される:
NetExtract[conv, "Weights"]NetExtract[conv, "KernelSize"]関連するガイド
テキスト
Wolfram Research (2016), NetExtract, Wolfram言語関数, https://reference.wolfram.com/language/ref/NetExtract.html (2020年に更新).
CMS
Wolfram Language. 2016. "NetExtract." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/NetExtract.html.
APA
Wolfram Language. (2016). NetExtract. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetExtract.html
BibTeX
@misc{reference.wolfram_2026_netextract, author="Wolfram Research", title="{NetExtract}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/NetExtract.html}", note=[Accessed: 05-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_netextract, organization={Wolfram Research}, title={NetExtract}, year={2020}, url={https://reference.wolfram.com/language/ref/NetExtract.html}, note=[Accessed: 05-November-2026]}