Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

✅ Optimized Swish activation function, for neural networks

License

NotificationsYou must be signed in to change notification settings

xyproto/swish

Repository files navigation

Build StatusGo Report CardGoDoc

An optimized Swish activation function (Ramachandran, Zoph and Le, 2017), for neural networks.

Screenshots

The graphs above were drawn using the program incmd/graph, which usesgoterm.

Benchmark Results

Using aSwish function that usesmath.Exp

First run:

goos: linuxgoarch: amd64pkg: github.com/xyproto/swishBenchmarkSwish07-8   200000000         8.93 ns/opBenchmarkSwish03-8   200000000         8.95 ns/opPASSok  github.com/xyproto/swish5.391s

Using the optimizedSwish function that usesexp256

goos: linuxgoarch: amd64pkg: github.com/xyproto/swishBenchmarkSwish07-8   2000000000         0.26 ns/opBenchmarkSwish03-8   2000000000         0.26 ns/opPASSok  github.com/xyproto/swish1.108s

The optimizedSwish function is34x faster than the one that usesmath.Exp, and quite a bit faster than my (apparently bad) attempt at a hand-written assembly version.

The average error (difference in output value) between the optimized and non-optimized version is+-0.0013 and the maximum error is+-0.0024. This is forx in the range[5,3]. See the program incmd/precision for how this was calculated.

0.000150.00001goos: linuxgoarch: amd64pkg: github.com/xyproto/swishBenchmarkSwishAssembly07-8      500000000                3.63 ns/opBenchmarkSwishAssembly03-8      500000000                3.65 ns/opBenchmarkSwish07-8              2000000000               0.30 ns/opBenchmarkSwish03-8              2000000000               0.26 ns/opBenchmarkSwishPrecise07-8       200000000                9.07 ns/opBenchmarkSwishPrecise03-8       200000000                9.25 ns/opPASSok      github.com/xyproto/swish        11.100s

I have no idea why the assembly version is so slow, but0.26 ns/op isn't bad for a non-hand-optimized version.

General info

About

✅ Optimized Swish activation function, for neural networks

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp