This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the following weight initialization functions: * Zeroes * Ones * HeU * HeN
- Loading branch information
1 parent
5b8842c
commit d8fb213
Showing
4 changed files
with
112 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package initwfn | ||
|
||
import G "gorgonia.org/gorgonia" | ||
|
||
// ZeroesConfig implements a configuration of a zero weight initializer | ||
type ZeroesConfig struct{} | ||
|
||
// Zeroes returns a new zeroes weight intializer | ||
func NewZeroes() (*InitWFn, error) { | ||
config := ZeroesConfig{} | ||
|
||
return newInitWFn(config) | ||
} | ||
|
||
// Type returns the type of the weight initializer created using this | ||
// config | ||
func (z ZeroesConfig) Type() Type { | ||
return Zeroes | ||
} | ||
|
||
// Create creates the Gorgonia weight initializer from this | ||
// initializer config | ||
func (z ZeroesConfig) Create() G.InitWFn { | ||
return G.Zeroes() | ||
} | ||
|
||
// OnesConfig implements a configuration of a weight initializer that | ||
// initializes all weights to 1. | ||
type OnesConfig struct{} | ||
|
||
// Ones returns a new zeroes weight intializer | ||
func NewOnes() (*InitWFn, error) { | ||
config := OnesConfig{} | ||
|
||
return newInitWFn(config) | ||
} | ||
|
||
// Type returns the type of the weight initializer created using this | ||
// config | ||
func (o OnesConfig) Type() Type { | ||
return Ones | ||
} | ||
|
||
// Create creates the Gorgonia weight initializer from this | ||
// initializer config | ||
func (o OnesConfig) Create() G.InitWFn { | ||
return G.Ones() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package initwfn | ||
|
||
import G "gorgonia.org/gorgonia" | ||
|
||
// HeUConfig implements a configuration of the He uniform | ||
// initialization algorithm. | ||
type HeUConfig struct { | ||
Gain float64 | ||
} | ||
|
||
// NewHeU returns a new He Uniform weight initializer | ||
func NewHeU(gain float64) (*InitWFn, error) { | ||
config := HeUConfig{ | ||
Gain: gain, | ||
} | ||
|
||
return newInitWFn(config) | ||
} | ||
|
||
// Type returns the type of initialization algorithm described by | ||
// the configuration. | ||
func (h HeUConfig) Type() Type { | ||
return HeU | ||
} | ||
|
||
// Create returns the weight initialization algorithm as a Gorgonia | ||
// InitWFn | ||
func (h HeUConfig) Create() G.InitWFn { | ||
return G.HeU(h.Gain) | ||
} | ||
|
||
// HeNConfig implements a configuration of the He normal | ||
// initialization algorithm. | ||
type HeNConfig struct { | ||
Gain float64 | ||
} | ||
|
||
// NewHeN returns a new He Nniform weight initializer | ||
func NewHeN(gain float64) (*InitWFn, error) { | ||
config := HeNConfig{ | ||
Gain: gain, | ||
} | ||
|
||
return newInitWFn(config) | ||
} | ||
|
||
// Type returns the type of initialization algorithm described by | ||
// the configuration. | ||
func (h HeNConfig) Type() Type { | ||
return HeN | ||
} | ||
|
||
// Create returns the weight initialization algorithm as a Gorgonia | ||
// InitWFn | ||
func (h HeNConfig) Create() G.InitWFn { | ||
return G.HeN(h.Gain) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.