FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TensorFlow.NET/src/TensorFlowNET.Core/Data/BatchDataset.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.Core
/
Data
/
BatchDataset.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (34 loc) · 1.17 KB
Breadcrumbs
TensorFlow.NET
/
src
/
TensorFlowNET.Core
/
Data
/
BatchDataset.cs
Copy path
File metadata and controls
38 lines (34 loc) · 1.17 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
using
System
;
using
System
.
Linq
;
using
static
Tensorflow
.
Binding
;
namespace
Tensorflow
{
/// <summary>
/// A `Dataset` that batches contiguous elements from its input.
/// </summary>
public
class
BatchDataset
:
UnaryDataset
{
Tensor
_batch_size
;
Tensor
_drop_remainder
;
public
BatchDataset
(
IDatasetV2
input_dataset
,
int
batch_size
,
bool
drop_remainder
=
false
)
:
base
(
input_dataset
)
{
_input_dataset
=
input_dataset
;
_batch_size
=
tf
.
convert_to_tensor
(
batch_size
,
dtype
:
TF_DataType
.
TF_INT64
,
name
:
"batch_size"
)
;
_drop_remainder
=
tf
.
convert_to_tensor
(
drop_remainder
,
dtype
:
TF_DataType
.
TF_BOOL
,
name
:
"drop_remainder"
)
;
if
(
drop_remainder
)
{
throw
new
NotImplementedException
(
""
)
;
}
else
{
structure
=
input_dataset
.
element_spec
.
Select
(
x
=>
x
.
_batch
(
-
1
)
)
.
ToArray
(
)
;
}
variant_tensor
=
ops
.
batch_dataset_v2
(
input_dataset
.
variant_tensor
,
_batch_size
,
_drop_remainder
,
output_types
,
output_shapes
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL