.Fluxloadmodel!

function defined in module Flux


			loadmodel!(dst, src)

Copy all the parameters (trainable and non-trainable) from src into dst.

Recursively walks dst and src together using Functors.children , and calling copyto! on parameter arrays or throwing an error when there is a mismatch. Non-array elements (such as activation functions) are not copied and need not match. Zero bias vectors and bias=false are considered equivalent (see extended help for more details).

See also Flux.state.

Examples


			
			
			
			
			julia
			>
			 
			dst
			 
			=
			 
			

	
			Chain
			(
			

	
			Dense
			(
			
			

	
			Flux
			.
			

	
			ones32
			(
			2
			,
			 
			5
			)
			,
			 
			
			

	
			Flux
			.
			

	
			ones32
			(
			2
			)
			,
			 
			tanh
			)
			,
			 
			

	
			Dense
			(
			
			2
			 
			=>
			 
			1
			
			;
			 
			
			bias
			 
			=
			 
			
			[
			1f0
			]
			)
			)
			

			

	
			Chain
			(
			
  
			

	
			Dense
			(
			
			5
			 
			=>
			 
			2
			,
			 
			tanh
			)
			,
			                  
			# 12 parameters
			
  
			

	
			Dense
			(
			
			2
			 
			=>
			 
			1
			)
			,
			                        
			# 3 parameters
			

			)
			                   
			# Total: 4 arrays, 15 parameters, 316 bytes.
			

			

			
			julia
			>
			 
			
			
			dst
			[
			1
			]
			.
			
			weight
			 
			 
			

	
			ones
			(
			2
			,
			 
			5
			)
			  
			# by construction
			

			true
			
			

			

			
			
			julia
			>
			 
			src
			 
			=
			 
			

	
			Chain
			(
			

	
			Dense
			(
			
			5
			 
			=>
			 
			2
			,
			 
			relu
			)
			,
			 
			

	
			Dense
			(
			
			2
			 
			=>
			 
			1
			,
			 
			
			bias
			=
			false
			)
			)
			;
			
			

			

			
			julia
			>
			 
			
			

	
			Flux
			.
			

			loadmodel!
			(
			dst
			,
			 
			src
			)
			;
			

			

			
			julia
			>
			 
			
			
			dst
			[
			1
			]
			.
			
			weight
			 
			 
			

	
			ones
			(
			2
			,
			 
			5
			)
			  
			# values changed
			

			false
			

			

			
			julia
			>
			 
			
			iszero
			(
			
			
			dst
			[
			2
			]
			.
			
			bias
			)
			

			true

Extended help

Throws an error when:

  • dst and src do not share the same fields (at any level)

  • the sizes of leaf nodes are mismatched between dst and src

  • copying non-array values to/from an array parameter (except inactive parameters described below)

  • dst is a "tied" parameter (i.e. refers to another parameter) and loaded into multiple times with mismatched source values

Inactive parameters can be encoded by using the boolean value false instead of an array. If dst == false and src is an all-zero array, no error will be raised (and no values copied); however, attempting to copy a non-zero array to an inactive parameter will throw an error. Likewise, copying a src value of false to any dst array is valid, but copying a src value of true will error.

Methods

There is 1 method for Flux.loadmodel!: