Commit d4a82aea authored by Jacky Lin's avatar Jacky Lin
Browse files

update

parent 97d96ad0
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
.idea
test
\ No newline at end of file
/*
* Author: Jacky Lin
* Date: 2021-02-17
* Programming Language Name: Go
* Compile Method:
* 1. Directly run the program: go run <filename>
* e.g. go run helloworld.go
* 2. Compile to executable and run:
* 2.1 go build <filename>
* 2.2 ./<filename>
* e.g. go build helloworld.go && ./helloworld
* Citation: Go essential training Online Class: Linkedin learning, formerly Lynda.com. (n.d.). Retrieved February 17, 2021, from https://www.linkedin.com/learning/go-essential-training/
*/
// This is the comment in go language
// Go is organized in packages
package main
// This is the import in go language
// fmt package contains print method
//that we would use to print "hello world"
import "fmt"
// In go we use func to define a function
// Function main will execute automatically in run time
func main () {
// We use the format package.function to use a function
// from imported package
// fmt.Println do the print in go
fmt.Println("Hello, World.")
}
package main
package digit_recognition
func main() {
$END$
}
package main
package digit_recognition
import (
"fmt"
"math"
"math/rand"
)
type Network struct {
numLayer int
size []int
bias []float64
weight []float64
}
func NewNetwork(size []int) (*Network, error) {
if len(size) < 2 {
return nil, fmt.Errorf("must have at least two layer of network")
}
n := &Network{
numLayer: len(size),
size: size,
bias: randomArray(len(size)),
weight: randomArray(len(size)),
}
return n, nil
}
func randomArray(size int) []float64 {
arr := make([]float64, size)
for i := 0; i < size; i++ {
arr[i] = rand.Float64()
}
return arr
}
func (n *Network) feedForward(in []int) {
for _, b := range n.bias {
for _, w := range n.weight {
in = mat.dot
}
}
}
// Basic Function
func sigmoid(x float64) float64 {
return 1.0 / (1.0 + math.Exp(x))
}
func sigmoidDeri(x float64) float64 {
return sigmoid(x) * (1 - sigmoid(x))
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment