diff --git a/layer/lstm.go b/layer/lstm.go index 472f357..b014f95 100644 --- a/layer/lstm.go +++ b/layer/lstm.go @@ -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 } diff --git a/layer/lstm_test.go b/layer/lstm_test.go index b7bc88d..5730b9a 100644 --- a/layer/lstm_test.go +++ b/layer/lstm_test.go @@ -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) @@ -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) diff --git a/layer/rnn.go b/layer/rnn.go index e120e4e..0817d3a 100644 --- a/layer/rnn.go +++ b/layer/rnn.go @@ -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 } diff --git a/layer/rnn_test.go b/layer/rnn_test.go index 922389b..abac837 100644 --- a/layer/rnn_test.go +++ b/layer/rnn_test.go @@ -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) @@ -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) diff --git a/model/lstm.go b/model/lstm.go index fd046f0..35129a0 100644 --- a/model/lstm.go +++ b/model/lstm.go @@ -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 } @@ -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)), }...) diff --git a/model/lstm_test.go b/model/lstm_test.go index 3a4ffab..1a1f2b1 100644 --- a/model/lstm_test.go +++ b/model/lstm_test.go @@ -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) diff --git a/model/mlp.go b/model/mlp.go index 7d1775a..31ae296 100644 --- a/model/mlp.go +++ b/model/mlp.go @@ -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 } diff --git a/model/mlp_test.go b/model/mlp_test.go index 3fc9dd8..4619e22 100644 --- a/model/mlp_test.go +++ b/model/mlp_test.go @@ -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) @@ -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)