Skip to content

Commit

Permalink
Rename option func
Browse files Browse the repository at this point in the history
  • Loading branch information
itsubaki committed Sep 11, 2024
1 parent fba71e1 commit f01c544
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion layer/lstm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type LSTMOptionFunc func(*LSTMT)

func LSTMWithSource(s randv2.Source) LSTMOptionFunc {
func WithLSTMSource(s randv2.Source) LSTMOptionFunc {
return func(l *LSTMT) {
l.s = s
}
Expand Down
4 changes: 2 additions & 2 deletions layer/lstm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func ExampleLSTM() {
l := L.LSTM(2, L.LSTMWithSource(rand.Const()))
l := L.LSTM(2, L.WithLSTMSource(rand.Const()))

x := variable.New(1)
y := l.Forward(x)
Expand Down Expand Up @@ -37,7 +37,7 @@ func ExampleLSTM() {
}

func ExampleLSTM_backward() {
l := L.LSTM(2, L.LSTMWithSource(rand.Const()))
l := L.LSTM(2, L.WithLSTMSource(rand.Const()))

x := variable.New(1)
y := l.First(x)
Expand Down
2 changes: 1 addition & 1 deletion layer/rnn.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type RNNOptionFunc func(*RNNT)

func RNNWithSource(s randv2.Source) RNNOptionFunc {
func WithRNNSource(s randv2.Source) RNNOptionFunc {
return func(l *RNNT) {
l.s = s
}
Expand Down
4 changes: 2 additions & 2 deletions layer/rnn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func ExampleRNN() {
l := L.RNN(2, L.RNNWithSource(rand.Const()))
l := L.RNN(2, L.WithRNNSource(rand.Const()))

x := variable.New(1)
y := l.Forward(x)
Expand All @@ -27,7 +27,7 @@ func ExampleRNN() {
}

func ExampleRNN_backward() {
l := L.RNN(2, L.RNNWithSource(rand.Const()))
l := L.RNN(2, L.WithRNNSource(rand.Const()))

x := variable.New(1)
y := l.First(x)
Expand Down
4 changes: 2 additions & 2 deletions model/lstm.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type LSTMOptionFunc func(*LSTM)

func LSTMWithSource(s randv2.Source) LSTMOptionFunc {
func WithLSTMSource(s randv2.Source) LSTMOptionFunc {
return func(l *LSTM) {
l.s = s
}
Expand All @@ -32,7 +32,7 @@ func NewLSTM(hiddenSize, outSize int, opts ...LSTMOptionFunc) *LSTM {
}

lstm.Layers = append(lstm.Layers, []L.Layer{
L.LSTM(hiddenSize, L.LSTMWithSource(lstm.s)),
L.LSTM(hiddenSize, L.WithLSTMSource(lstm.s)),
L.Linear(outSize, L.WithSource(lstm.s)),
}...)

Expand Down
2 changes: 1 addition & 1 deletion model/lstm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ExampleLSTM() {
}

func ExampleLSTM_backward() {
m := model.NewLSTM(1, 1, model.LSTMWithSource(rand.Const()))
m := model.NewLSTM(1, 1, model.WithLSTMSource(rand.Const()))

x := variable.New(1, 2)
y := m.Forward(x)
Expand Down
4 changes: 2 additions & 2 deletions model/mlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type MLPOpts struct {

type MLPOptionFunc func(*MLP)

func MLPWithSource(s randv2.Source) MLPOptionFunc {
func WithMLPSource(s randv2.Source) MLPOptionFunc {
return func(l *MLP) {
l.s = s
}
}

func MLPWithActivation(activation Activation) MLPOptionFunc {
func WithMLPActivation(activation Activation) MLPOptionFunc {
return func(l *MLP) {
l.Activation = activation
}
Expand Down
8 changes: 4 additions & 4 deletions model/mlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func ExampleMLP() {

func ExampleMLP_backward() {
m := model.NewMLP([]int{5, 1},
model.MLPWithSource(rand.Const()),
model.MLPWithActivation(F.ReLU),
model.WithMLPSource(rand.Const()),
model.WithMLPActivation(F.ReLU),
)

x := variable.New(1, 2)
Expand All @@ -45,8 +45,8 @@ func ExampleMLP_backward() {

func ExampleMLP_cleargrads() {
m := model.NewMLP([]int{5, 1},
model.MLPWithSource(rand.Const()),
model.MLPWithActivation(F.ReLU),
model.WithMLPSource(rand.Const()),
model.WithMLPActivation(F.ReLU),
)

x := variable.New(1, 2)
Expand Down

0 comments on commit f01c544

Please sign in to comment.