FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/src/TensorFlowNET.Core/Data/Datasets.cs at master · pathway27/TensorFlow.NET · GitHub
pathway27
/
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.Core
/
Data
/
Datasets.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (40 loc) · 1.37 KB
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Core
/
Data
/
Datasets.cs
Copy path
File metadata and controls
46 lines (40 loc) · 1.37 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
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Text
;
using
NumSharp
;
namespace
Tensorflow
{
public
class
Datasets
<
TDataSet
>
where
TDataSet
:
IDataSet
{
public
TDataSet
Train
{
get
;
private
set
;
}
public
TDataSet
Validation
{
get
;
private
set
;
}
public
TDataSet
Test
{
get
;
private
set
;
}
public
Datasets
(
TDataSet
train
,
TDataSet
validation
,
TDataSet
test
)
{
Train
=
train
;
Validation
=
validation
;
Test
=
test
;
}
public
(
NDArray
,
NDArray
)
Randomize
(
NDArray
x
,
NDArray
y
)
{
var
perm
=
np
.
random
.
permutation
(
y
.
shape
[
0
]
)
;
np
.
random
.
shuffle
(
perm
)
;
return
(
x
[
perm
]
,
y
[
perm
]
)
;
}
/// <summary>
/// selects a few number of images determined by the batch_size variable (if you don't know why, read about Stochastic Gradient Method)
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <returns></returns>
public
(
NDArray
,
NDArray
)
GetNextBatch
(
NDArray
x
,
NDArray
y
,
int
start
,
int
end
)
{
var
slice
=
new
Slice
(
start
,
end
)
;
var
x_batch
=
x
[
slice
]
;
var
y_batch
=
y
[
slice
]
;
return
(
x_batch
,
y_batch
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL