Products
  • Wolfram|One

    The definitive Wolfram Language and notebook experience

  • Mathematica

    The original technical computing environment

  • Wolfram Notebook Assistant + LLM Kit

    All-in-one AI assistance for your Wolfram experience

  • System Modeler
  • Wolfram Player
  • Finance Platform
  • Wolfram Engine
  • Enterprise Private Cloud
  • Application Server
  • Wolfram|Alpha Notebook Edition
  • Wolfram Cloud App
  • Wolfram Player App

More mobile apps

Core Technologies of Wolfram Products

  • Wolfram Language
  • Computable Data
  • Wolfram Notebooks
  • AI & Linguistic Understanding

Deployment Options

  • Wolfram Cloud
  • wolframscript
  • Wolfram Engine Community Edition
  • Wolfram LLM API
  • WSTPServer
  • Wolfram|Alpha APIs

From the Community

  • Function Repository
  • Community Paclet Repository
  • Example Repository
  • Neural Net Repository
  • Prompt Repository
  • Wolfram Demonstrations
  • Data Repository
  • Group & Organizational Licensing
  • All Products
Consulting & Solutions

We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

  • Data & Computational Intelligence
  • Model-Based Design
  • Algorithm Development
  • Wolfram|Alpha for Business
  • Blockchain Technology
  • Education Technology
  • Quantum Computation

WolframConsulting.com

Wolfram Solutions

  • Data Science
  • Artificial Intelligence
  • Biosciences
  • Healthcare Intelligence
  • Sustainable Energy
  • Control Systems
  • Enterprise Wolfram|Alpha
  • Blockchain Labs

More Wolfram Solutions

Wolfram Solutions For Education

  • Research Universities
  • Colleges & Teaching Universities
  • Junior & Community Colleges
  • High Schools
  • Educational Technology
  • Computer-Based Math

More Solutions for Education

  • Contact Us
Learning & Support

Get Started

  • Wolfram Language Introduction
  • Fast Intro for Programmers
  • Fast Intro for Math Students
  • Wolfram Language Documentation

More Learning

  • Highlighted Core Areas
  • Demonstrations
  • YouTube
  • Daily Study Groups
  • Wolfram Schools and Programs
  • Books

Grow Your Skills

  • Wolfram U

    Courses in computing, science, life and more

  • Community

    Learn, solve problems and share ideas.

  • Blog

    News, views and insights from Wolfram

  • Resources for

    Software Developers

Tech Support

  • Contact Us
  • Support FAQs
  • Support FAQs
  • Contact Us
Company
  • About Wolfram
  • Career Center
  • All Sites & Resources
  • Connect & Follow
  • Contact Us

Work with Us

  • Student Ambassador Initiative
  • Wolfram for Startups
  • Student Opportunities
  • Jobs Using Wolfram Language

Educational Programs for Adults

  • Summer School
  • Winter School

Educational Programs for Youth

  • Middle School Camp
  • High School Research Program
  • Computational Adventures

Read

  • Stephen Wolfram's Writings
  • Wolfram Blog
  • Wolfram Tech | Books
  • Wolfram Media
  • Complex Systems

Educational Resources

  • Wolfram MathWorld
  • Wolfram in STEM/STEAM
  • Wolfram Challenges
  • Wolfram Problem Generator

Wolfram Initiatives

  • Wolfram Science
  • Wolfram Foundation
  • History of Mathematics Project

Events

  • Stephen Wolfram Livestreams
  • Online & In-Person Events
  • Contact Us
  • Connect & Follow
Wolfram|Alpha
  • Your Account
  • User Portal
  • Wolfram Cloud
  • Products
    • Wolfram|One
    • Mathematica
    • Wolfram Notebook Assistant + LLM Kit
    • System Modeler
    • Wolfram Player
    • Finance Platform
    • Wolfram|Alpha Notebook Edition
    • Wolfram Engine
    • Enterprise Private Cloud
    • Application Server
    • Wolfram Cloud App
    • Wolfram Player App

    More mobile apps

    • Core Technologies
      • Wolfram Language
      • Computable Data
      • Wolfram Notebooks
      • AI & Linguistic Understanding
    • Deployment Options
      • Wolfram Cloud
      • wolframscript
      • Wolfram Engine Community Edition
      • Wolfram LLM API
      • WSTPServer
      • Wolfram|Alpha APIs
    • From the Community
      • Function Repository
      • Community Paclet Repository
      • Example Repository
      • Neural Net Repository
      • Prompt Repository
      • Wolfram Demonstrations
      • Data Repository
    • Group & Organizational Licensing
    • All Products
  • Consulting & Solutions

    We deliver solutions for the AI era—combining symbolic computation, data-driven insights and deep technical expertise

    WolframConsulting.com

    Wolfram Solutions

    • Data Science
    • Artificial Intelligence
    • Biosciences
    • Healthcare Intelligence
    • Sustainable Energy
    • Control Systems
    • Enterprise Wolfram|Alpha
    • Blockchain Labs

    More Wolfram Solutions

    Wolfram Solutions For Education

    • Research Universities
    • Colleges & Teaching Universities
    • Junior & Community Colleges
    • High Schools
    • Educational Technology
    • Computer-Based Math

    More Solutions for Education

    • Contact Us
  • Learning & Support

    Get Started

    • Wolfram Language Introduction
    • Fast Intro for Programmers
    • Fast Intro for Math Students
    • Wolfram Language Documentation

    Grow Your Skills

    • Wolfram U

      Courses in computing, science, life and more

    • Community

      Learn, solve problems and share ideas.

    • Blog

      News, views and insights from Wolfram

    • Resources for

      Software Developers
    • Tech Support
      • Contact Us
      • Support FAQs
    • More Learning
      • Highlighted Core Areas
      • Demonstrations
      • YouTube
      • Daily Study Groups
      • Wolfram Schools and Programs
      • Books
    • Support FAQs
    • Contact Us
  • Company
    • About Wolfram
    • Career Center
    • All Sites & Resources
    • Connect & Follow
    • Contact Us

    Work with Us

    • Student Ambassador Initiative
    • Wolfram for Startups
    • Student Opportunities
    • Jobs Using Wolfram Language

    Educational Programs for Adults

    • Summer School
    • Winter School

    Educational Programs for Youth

    • Middle School Camp
    • High School Research Program
    • Computational Adventures

    Read

    • Stephen Wolfram's Writings
    • Wolfram Blog
    • Wolfram Tech | Books
    • Wolfram Media
    • Complex Systems
    • Educational Resources
      • Wolfram MathWorld
      • Wolfram in STEM/STEAM
      • Wolfram Challenges
      • Wolfram Problem Generator
    • Wolfram Initiatives
      • Wolfram Science
      • Wolfram Foundation
      • History of Mathematics Project
    • Events
      • Stephen Wolfram Livestreams
      • Online & In-Person Events
    • Contact Us
    • Connect & Follow
  • Wolfram|Alpha
  • Wolfram Cloud
  • Your Account
  • User Portal
Wolfram Language & System Documentation Center
NetReplacePart
  • See Also
    • NetReplace
    • NetExtract
    • NetTake
    • NetRename
    • NetEncoder
    • NetDecoder
    • NetChain
    • NetGraph
    • ReplacePart
  • Related Guides
    • Neural Network Construction & Properties
    • Neural Network Operations
    • Neural Networks
  • Tech Notes
    • Neural Networks in the Wolfram Language
    • See Also
      • NetReplace
      • NetExtract
      • NetTake
      • NetRename
      • NetEncoder
      • NetDecoder
      • NetChain
      • NetGraph
      • ReplacePart
    • Related Guides
      • Neural Network Construction & Properties
      • Neural Network Operations
      • Neural Networks
    • Tech Notes
      • Neural Networks in the Wolfram Language

NetReplacePart[layer,"array"value]

replaces an array within a layer, returning a new layer.

NetReplacePart[net,"port"type]

returns a new layer or network in which an input or output port has the specified type.

NetReplacePart[net,"input"encoder]

attaches a NetEncoder[…] to a specified input port.

NetReplacePart[net,"output"decoder]

attaches a NetDecoder[…] to a specified output port.

NetReplacePart[net,lspeclayer]

returns a new NetChain or NetGraph in which the layer identified by lspec has been replaced.

NetReplacePart[net,NetArray[name]value]

sets a shared array within a network or layer to a specified value.

NetReplacePart[coder,"param"value]

returns a new NetEncoder[…] or NetDecoder[…] in which a parameter has been replaced.

NetReplacePart[net,{lspec,pspec}value]

makes a replacement of a part pspec of a layer or coder lspec within a NetGraph or NetChain.

NetReplacePart[…,{spec1val1,spec2val2,…}]

makes multiple simultaneous replacements.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Properties & Relations  
See Also
Tech Notes
Related Guides
History
Cite this Page
BUILT-IN SYMBOL
  • See Also
    • NetReplace
    • NetExtract
    • NetTake
    • NetRename
    • NetEncoder
    • NetDecoder
    • NetChain
    • NetGraph
    • ReplacePart
  • Related Guides
    • Neural Network Construction & Properties
    • Neural Network Operations
    • Neural Networks
  • Tech Notes
    • Neural Networks in the Wolfram Language
    • See Also
      • NetReplace
      • NetExtract
      • NetTake
      • NetRename
      • NetEncoder
      • NetDecoder
      • NetChain
      • NetGraph
      • ReplacePart
    • Related Guides
      • Neural Network Construction & Properties
      • Neural Network Operations
      • Neural Networks
    • Tech Notes
      • Neural Networks in the Wolfram Language

NetReplacePart

NetReplacePart[layer,"array"value]

replaces an array within a layer, returning a new layer.

NetReplacePart[net,"port"type]

returns a new layer or network in which an input or output port has the specified type.

NetReplacePart[net,"input"encoder]

attaches a NetEncoder[…] to a specified input port.

NetReplacePart[net,"output"decoder]

attaches a NetDecoder[…] to a specified output port.

NetReplacePart[net,lspeclayer]

returns a new NetChain or NetGraph in which the layer identified by lspec has been replaced.

NetReplacePart[net,NetArray[name]value]

sets a shared array within a network or layer to a specified value.

NetReplacePart[coder,"param"value]

returns a new NetEncoder[…] or NetDecoder[…] in which a parameter has been replaced.

NetReplacePart[net,{lspec,pspec}value]

makes a replacement of a part pspec of a layer or coder lspec within a NetGraph or NetChain.

NetReplacePart[…,{spec1val1,spec2val2,…}]

makes multiple simultaneous replacements.

Details

  • NetReplacePart can replace layer parameters, layer arrays, layers, encoders, decoders, encoder parameters, decoder parameters, input array sizes and output array sizes.
  • The part specifications supported by NetReplacePart are identical to those used by NetExtract.
  • When replacing an array within a layer, the new value must have the same dimensions as the original array.
  • When replacing an input or an output in order to fully specify a partially specified network, any of the following values can be used to specify the type of the port:
  • "Real"a single real number
    "Integer"a single integer
    na vector of length n
    {n1,n2,…}an array of dimensions n1×n2×…
    "Varying"a variable-length vector
    {"Varying",n2,n3,…}an array whose first dimension is variable and remaining dimensions are n2×n3×…
    Automatican array with a shape that should be inferred
    NetEncoder[…]an encoder (for input ports)
    NetDecoder[…]a decoder (for output ports)
  • An encoder or decoder can be removed from a port by specifying the value None.
  • Changing the output dimension of a NetChain or NetGraph is in general possible, but might require changing intermediate layers, using syntax like NetReplacePart[net,{layernamenewlayer,"Output"newoutput}].
  • NetReplacePart will fail if the replacement specifications lead to a net with incompatible dimensions.

Examples

open all close all

Basic Examples  (1)

Obtain a trained model:

Obtain a new model in which the input NetEncoder has been removed:

Obtain a new model that can be trained on a different set of classes:

Obtain a new model in which the first activation layer has been replaced:

Obtain a new model in which the first convolution biases have been randomized:

Scope  (10)

Create an existing model that contains a DropoutLayer with dropout probability 0.5:

Update the dropout probability:

Create a linear layer with no weight matrix specified:

Insert specific weights and biases:

Evaluate the layer on an input:

Create a layer without an input encoder:

Attach a "Class" encoder to the input of the layer, which embeds the classes as {1,0} and {0,1}:

The resulting layer can now take the values True and False as inputs:

Add type information to an existing net:

Remove a decoder from a net:

Reshape an existing layer to have different input and output dimensions. Create a layer with a specific NetEncoder:

Apply the layer to an input:

Replace the input NetEncoder and output NetDecoder:

Apply the resized layer to an input:

Replace the second layer within a NetChain:

Replace a property of an existing NetEncoder:

Replace the value of a shared array in a network:

The weights have been replaced by the new value and are still shared:

Turn a network that processes fixed-length sequences into an equivalent network that handles variable-length sequences:

Turn a network that processes strings in a fixed-length fashion into an equivalent network that handles variable-length strings without padding nor clipping:

Properties & Relations  (1)

The part specifications supported by NetReplacePart are identical to those used by NetExtract. Replace the weights of the third layer of a NetChain:

Use the same specification to extract the weights:

See Also

NetReplace  NetExtract  NetTake  NetRename  NetEncoder  NetDecoder  NetChain  NetGraph  ReplacePart

Tech Notes

    ▪
  • Neural Networks in the Wolfram Language

Related Guides

    ▪
  • Neural Network Construction & Properties
  • ▪
  • Neural Network Operations
  • ▪
  • Neural Networks

History

Introduced in 2016 (11.0) | Updated in 2020 (12.1)

Wolfram Research (2016), NetReplacePart, Wolfram Language function, https://reference.wolfram.com/language/ref/NetReplacePart.html (updated 2020).

Text

Wolfram Research (2016), NetReplacePart, Wolfram Language function, https://reference.wolfram.com/language/ref/NetReplacePart.html (updated 2020).

CMS

Wolfram Language. 2016. "NetReplacePart." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/NetReplacePart.html.

APA

Wolfram Language. (2016). NetReplacePart. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetReplacePart.html

BibTeX

@misc{reference.wolfram_2025_netreplacepart, author="Wolfram Research", title="{NetReplacePart}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/NetReplacePart.html}", note=[Accessed: 01-December-2025]}

BibLaTeX

@online{reference.wolfram_2025_netreplacepart, organization={Wolfram Research}, title={NetReplacePart}, year={2020}, url={https://reference.wolfram.com/language/ref/NetReplacePart.html}, note=[Accessed: 01-December-2025]}

Top
Introduction for Programmers
Introductory Book
Wolfram Function Repository | Wolfram Data Repository | Wolfram Data Drop | Wolfram Language Products
Top
  • Products
  • Wolfram|One
  • Mathematica
  • Notebook Assistant + LLM Kit
  • System Modeler

  • Wolfram|Alpha Notebook Edition
  • Wolfram|Alpha Pro
  • Mobile Apps

  • Wolfram Player
  • Wolfram Engine

  • Volume & Site Licensing
  • Server Deployment Options
  • Consulting
  • Wolfram Consulting
  • Repositories
  • Data Repository
  • Function Repository
  • Community Paclet Repository
  • Neural Net Repository
  • Prompt Repository

  • Wolfram Language Example Repository
  • Notebook Archive
  • Wolfram GitHub
  • Learning
  • Wolfram U
  • Wolfram Language Documentation
  • Webinars & Training
  • Educational Programs

  • Wolfram Language Introduction
  • Fast Introduction for Programmers
  • Fast Introduction for Math Students
  • Books

  • Wolfram Community
  • Wolfram Blog
  • Public Resources
  • Wolfram|Alpha
  • Wolfram Problem Generator
  • Wolfram Challenges

  • Computer-Based Math
  • Computational Thinking
  • Computational Adventures

  • Demonstrations Project
  • Wolfram Data Drop
  • MathWorld
  • Wolfram Science
  • Wolfram Media Publishing
  • Customer Resources
  • Store
  • Product Downloads
  • User Portal
  • Your Account
  • Organization Access

  • Support FAQ
  • Contact Support
  • Company
  • About Wolfram
  • Careers
  • Contact
  • Events
Wolfram Community Wolfram Blog
Legal & Privacy Policy
WolframAlpha.com | WolframCloud.com
© 2025 Wolfram
© 2025 Wolfram | Legal & Privacy Policy |
English