activation

package
v0.0.0-...-885409b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identity

func Identity(v float64) float64

Identity returns the input value.

Example
package main

import (
	"fmt"

	"github.com/itsubaki/neu/activation"
)

func main() {
	fmt.Println(activation.Identity(100))

}
Output:

100

func ReLU

func ReLU(x float64) float64
Example
package main

import (
	"fmt"

	"github.com/itsubaki/neu/activation"
)

func main() {
	fmt.Println(activation.ReLU(-1.0))
	fmt.Println(activation.ReLU(-0.1))
	fmt.Println(activation.ReLU(0.0))
	fmt.Println(activation.ReLU(0.1))
	fmt.Println(activation.ReLU(1.0))

}
Output:

0
0
0
0.1
1

func Sigmoid

func Sigmoid(x float64) float64
Example
package main

import (
	"fmt"

	"github.com/itsubaki/neu/activation"
)

func main() {
	fmt.Println(activation.Sigmoid(-1e+7))
	fmt.Println(activation.Sigmoid(0.0))
	fmt.Println(activation.Sigmoid(1e+7))

}
Output:

0
0.5
1

func Softmax

func Softmax(a []float64) []float64

Softmax returns the softmax of the input vector.

Example
package main

import (
	"fmt"

	"github.com/itsubaki/neu/activation"
)

func main() {
	y := activation.Softmax([]float64{0.3, 2.9, 4.0})
	fmt.Println(y)

	var sum float64
	for i := range y {
		sum = sum + y[i]
	}
	fmt.Println(sum)

}
Output:

[0.01821127329554753 0.24519181293507386 0.7365969137693786]
1

func Step

func Step(x float64) float64
Example
package main

import (
	"fmt"

	"github.com/itsubaki/neu/activation"
)

func main() {
	fmt.Println(activation.Step(-1.0))
	fmt.Println(activation.Step(-0.1))
	fmt.Println(activation.Step(0.0))
	fmt.Println(activation.Step(0.1))
	fmt.Println(activation.Step(1.0))

}
Output:

0
0
0
1
1

func Tanh

func Tanh(x float64) float64
Example
package main

import (
	"fmt"

	"github.com/itsubaki/neu/activation"
)

func main() {
	fmt.Println(activation.Tanh(-1e+7))
	fmt.Println(activation.Tanh(0.0))
	fmt.Println(activation.Tanh(1e+7))

}
Output:

-1
0
1

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL