-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished implementation to export a net to File, at the moment it is …
…working only for fully connected layers, added tutorial, added Mish activation function, changed some names to methods that were not consistent with naming convention
- Loading branch information
1 parent
a1c0ee2
commit a405bd0
Showing
22 changed files
with
965 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ Release/* | |
.cproject | ||
.project | ||
.settings/* | ||
*.orig | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Authors | ||
======= | ||
|
||
The authors and developers of MiniDNN are: | ||
- [Yixuan Qiu](https://statr.me/about/) (<yixuanq@gmail.com>) | ||
- [Giovanni Stabile](https://www.giovannistabile.com/) (<gstabile@sissa.it>) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,11 @@ class Identity | |
{ | ||
G.noalias() = F; | ||
} | ||
|
||
static std::string return_type() | ||
{ | ||
return "Identity"; | ||
} | ||
}; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef ACTIVATION_MISH_H_ | ||
#define ACTIVATION_MISH_H_ | ||
|
||
#include <Eigen/Core> | ||
#include "../Config.h" | ||
|
||
namespace MiniDNN | ||
{ | ||
|
||
|
||
/// | ||
/// \ingroup Activations | ||
/// | ||
/// The Mish activation function | ||
/// | ||
/// from : https://arxiv.org/abs/1908.08681 | ||
/// | ||
class Mish | ||
{ | ||
private: | ||
typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> Matrix; | ||
|
||
public: | ||
// a = activation(z) = max(z, 0) | ||
// Z = [z1, ..., zn], A = [a1, ..., an], n observations | ||
static inline void activate(const Matrix& Z, Matrix& A) | ||
{ | ||
A.array() = Z.array() * ((((Z.array()).exp()).log1p()).tanh()); | ||
} | ||
|
||
// Apply the Jacobian matrix J to a vector f | ||
// J = d_a / d_z = diag(sign(a)) = diag(a > 0) | ||
// g = J * f = (a > 0) .* f | ||
// Z = [z1, ..., zn], G = [g1, ..., gn], F = [f1, ..., fn] | ||
// Note: When entering this function, Z and G may point to the same matrix | ||
static inline void apply_jacobian(const Matrix& Z, const Matrix& A, | ||
const Matrix& F, Matrix& G) | ||
{ | ||
Matrix tempSoftplus; | ||
Matrix tempSech; | ||
Matrix ex; | ||
ex.array() = Z.array().exp(); | ||
tempSoftplus.array() = ex.array().log1p(); | ||
tempSech.array() = Scalar(1) / (tempSoftplus.array().cosh()); | ||
G.array() = tempSoftplus.array().tanh() + Z.array() * ex.array() * | ||
tempSech.array() * (tempSech.array() / (Scalar(1) + ex.array())) * F.array(); | ||
} | ||
|
||
static std::string return_type() | ||
{ | ||
return "Mish"; | ||
} | ||
}; | ||
|
||
|
||
} // namespace MiniDNN | ||
|
||
|
||
#endif /* ACTIVATION_MISH_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.