FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/src/TensorFlowNET.Keras/Regularizers.cs at master · ehtick/TensorFlow.NET · GitHub
ehtick
/
TensorFlow.NET
Public
forked from
SciSharp/TensorFlow.NET
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Keras
/
Regularizers.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (43 loc) · 1.32 KB
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Keras
/
Regularizers.cs
Copy path
File metadata and controls
51 lines (43 loc) · 1.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using
Tensorflow
.
Operations
.
Regularizers
;
namespace
Tensorflow
.
Keras
{
public
class
Regularizers
:
IRegularizerApi
{
private
static
Dictionary
<
string
,
IRegularizer
>
_nameActivationMap
;
public
IRegularizer
l1
(
float
l1
=
0.01f
)
=>
new
L1
(
l1
)
;
public
IRegularizer
l2
(
float
l2
=
0.01f
)
=>
new
L2
(
l2
)
;
//From TF source
//# The default value for l1 and l2 are different from the value in l1_l2
//# for backward compatibility reason. Eg, L1L2(l2=0.1) will only have l2
//# and no l1 penalty.
public
IRegularizer
l1l2
(
float
l1
=
0.00f
,
float
l2
=
0.00f
)
=>
new
L1L2
(
l1
,
l2
)
;
static
Regularizers
(
)
{
_nameActivationMap
=
new
Dictionary
<
string
,
IRegularizer
>
(
)
;
_nameActivationMap
[
"L1"
]
=
new
L1
(
)
;
_nameActivationMap
[
"L1"
]
=
new
L2
(
)
;
_nameActivationMap
[
"L1"
]
=
new
L1L2
(
)
;
}
public
IRegularizer
L1
=>
l1
(
)
;
public
IRegularizer
L2
=>
l2
(
)
;
public
IRegularizer
L1L2
=>
l1l2
(
)
;
public
IRegularizer
GetRegularizerFromName
(
string
name
)
{
if
(
name
==
null
)
{
throw
new
Exception
(
$
"Regularizer name cannot be null"
)
;
}
if
(
!
_nameActivationMap
.
TryGetValue
(
name
,
out
var
res
)
)
{
throw
new
Exception
(
$
"Regularizer
{
name
}
not found"
)
;
}
else
{
return
res
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL