FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/test/TensorFlowNET.UnitTest/Numpy/Math.Test.cs at master · z3rg/TensorFlow.NET · GitHub
z3rg
TensorFlow.NET
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TensorFlow.NET
/
test
/
TensorFlowNET.UnitTest
/
Numpy
/
Math.Test.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (61 loc) · 1.74 KB
Breadcrumbs
TensorFlow.NET
/
test
/
TensorFlowNET.UnitTest
/
Numpy
/
Math.Test.cs
Copy path
File metadata and controls
69 lines (61 loc) · 1.74 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using
Microsoft
.
VisualStudio
.
TestTools
.
UnitTesting
;
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
System
.
Text
;
using
Tensorflow
;
using
Tensorflow
.
NumPy
;
namespace
TensorFlowNET
.
UnitTest
.
NumPy
{
/// <summary>
/// https://numpy.org/doc/stable/reference/generated/numpy.prod.html
/// </summary>
[
TestClass
]
public
class
MathTest
:
EagerModeTestBase
{
[
TestMethod
]
public
void
prod
(
)
{
var
p
=
np
.
prod
(
1.0
,
2.0
)
;
Assert
.
AreEqual
(
p
,
2.0
)
;
p
=
np
.
prod
(
new
[
,
]
{
{
1.0
,
2.0
}
,
{
3.0
,
4.0
}
}
)
;
Assert
.
AreEqual
(
p
,
24.0
)
;
p
=
np
.
prod
(
new
[
,
]
{
{
1.0
,
2.0
}
,
{
3.0
,
4.0
}
}
,
axis
:
1
)
;
Assert
.
AreEqual
(
p
.
shape
,
2
)
;
Assert
.
IsTrue
(
Equal
(
p
.
ToArray
<
double
>
(
)
,
new
[
]
{
2.0
,
12.0
}
)
)
;
}
[
TestMethod
]
public
void
astype
(
)
{
var
x
=
np
.
array
(
new
byte
[
]
{
1
,
100
,
200
}
)
;
var
x1
=
x
.
astype
(
np
.
float32
)
;
Assert
.
AreEqual
(
x1
[
2
]
,
200f
)
;
}
[
TestMethod
]
public
void
divide
(
)
{
var
x
=
np
.
array
(
new
float
[
]
{
1
,
100
,
200
}
)
;
var
y
=
x
/
2
;
Assert
.
AreEqual
(
y
.
dtype
,
np
.
float32
)
;
}
[
TestMethod
]
public
void
sin
(
)
{
var
x
=
np
.
sin
(
np
.
pi
/
2
)
;
Assert
.
AreEqual
(
x
,
1d
)
;
}
[
TestMethod
]
public
void
cos
(
)
{
var
x
=
np
.
cos
(
np
.
pi
/
2
)
;
Assert
.
AreEqual
(
x
,
6.123233995736766e-17
)
;
}
[
TestMethod
]
public
void
power
(
)
{
var
x
=
np
.
arange
(
6
)
;
var
y
=
np
.
power
(
x
,
3
)
;
Assert
.
AreEqual
(
y
,
new
[
]
{
0
,
1
,
8
,
27
,
64
,
125
}
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL