Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
face
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
face
Commits
e82cc5ab
Commit
e82cc5ab
authored
Jul 28, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed tinyYolov2 implementation
parent
886cf99e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
TinyYolov2.ts
src/tinyYolov2/TinyYolov2.ts
+10
-9
convWithBatchNorm.ts
src/tinyYolov2/convWithBatchNorm.ts
+2
-1
No files found.
src/tinyYolov2/TinyYolov2.ts
View file @
e82cc5ab
...
...
@@ -25,22 +25,23 @@ export class TinyYolov2 extends NeuralNetwork<NetParams> {
}
const
out
=
tf
.
tidy
(()
=>
{
const
batchTensor
=
input
.
toBatchTensor
(
416
).
div
(
tf
.
scalar
(
255
)).
toFloat
()
//const batchTensor = input.toBatchTensor(416).div(tf.scalar(255)).toFloat() as tf.Tensor4D
let
out
=
tf
.
pad
(
batchTensor
,
[[
0
,
0
],
[
1
,
1
],
[
1
,
1
],
[
0
,
0
]])
as
tf
.
Tensor4D
// TODO: fix boxes after padding
const
batchTensor
=
tf
.
image
.
resizeBilinear
(
input
.
inputs
[
0
],
[
416
,
416
]).
toFloat
().
div
(
tf
.
scalar
(
255
)).
expandDims
()
as
tf
.
Tensor4D
out
=
convWithBatchNorm
(
out
,
params
.
conv0
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
valid
'
)
let
out
=
convWithBatchNorm
(
batchTensor
,
params
.
conv0
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
same
'
)
out
=
convWithBatchNorm
(
out
,
params
.
conv1
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
valid
'
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
same
'
)
out
=
convWithBatchNorm
(
out
,
params
.
conv2
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
valid
'
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
same
'
)
out
=
convWithBatchNorm
(
out
,
params
.
conv3
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
valid
'
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
same
'
)
out
=
convWithBatchNorm
(
out
,
params
.
conv4
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
valid
'
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
2
,
2
],
'
same
'
)
out
=
convWithBatchNorm
(
out
,
params
.
conv5
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
1
,
1
],
'
valid
'
)
out
=
tf
.
maxPool
(
out
,
[
2
,
2
],
[
1
,
1
],
'
same
'
)
out
=
convWithBatchNorm
(
out
,
params
.
conv6
)
out
=
convWithBatchNorm
(
out
,
params
.
conv7
)
out
=
convLayer
(
out
,
params
.
conv8
,
'valid'
,
false
)
...
...
src/tinyYolov2/convWithBatchNorm.ts
View file @
e82cc5ab
...
...
@@ -5,7 +5,8 @@ import { ConvWithBatchNorm } from './types';
export
function
convWithBatchNorm
(
x
:
tf
.
Tensor4D
,
params
:
ConvWithBatchNorm
):
tf
.
Tensor4D
{
return
tf
.
tidy
(()
=>
{
let
out
=
tf
.
conv2d
(
x
,
params
.
conv
.
filters
,
[
1
,
1
],
'valid'
)
let
out
=
tf
.
pad
(
x
,
[[
0
,
0
],
[
1
,
1
],
[
1
,
1
],
[
0
,
0
]])
as
tf
.
Tensor4D
out
=
tf
.
conv2d
(
out
,
params
.
conv
.
filters
,
[
1
,
1
],
'valid'
)
out
=
tf
.
sub
(
out
,
params
.
bn
.
sub
)
out
=
tf
.
mul
(
out
,
params
.
bn
.
truediv
)
out
=
tf
.
add
(
out
,
params
.
conv
.
bias
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment