Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
c118dcb6
Commit
c118dcb6
authored
Jun 10, 2016
by
Davis King
Browse files
Made resizable_tensor construction and assignment from matrices automatically
set the size of the tensor.
parent
087f9f17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
1 deletion
+96
-1
dlib/dnn/tensor.h
dlib/dnn/tensor.h
+32
-1
dlib/dnn/tensor_abstract.h
dlib/dnn/tensor_abstract.h
+64
-0
No files found.
dlib/dnn/tensor.h
View file @
c118dcb6
...
...
@@ -267,6 +267,15 @@ namespace dlib
)
{}
template
<
typename
EXP
>
resizable_tensor
(
const
matrix_exp
<
EXP
>&
item
)
{
set_size
(
item
.
nr
(),
item
.
nc
());
*
this
=
item
;
}
explicit
resizable_tensor
(
long
n_
,
long
k_
=
1
,
long
nr_
=
1
,
long
nc_
=
1
)
...
...
@@ -319,12 +328,34 @@ namespace dlib
}
template
<
typename
EXP
>
resizable_tensor
&
operator
=
(
const
matrix_exp
<
EXP
>&
item
)
resizable_tensor
&
operator
=
(
const
matrix_exp
<
EXP
>&
item
)
{
set_size
(
item
.
nr
(),
item
.
nc
());
tensor
::
operator
=
(
item
);
return
*
this
;
}
template
<
typename
EXP
>
resizable_tensor
&
operator
+=
(
const
matrix_exp
<
EXP
>&
item
)
{
set_size
(
item
.
nr
(),
item
.
nc
());
tensor
::
operator
+=
(
item
);
return
*
this
;
}
template
<
typename
EXP
>
resizable_tensor
&
operator
-=
(
const
matrix_exp
<
EXP
>&
item
)
{
set_size
(
item
.
nr
(),
item
.
nc
());
tensor
::
operator
-=
(
item
);
return
*
this
;
}
void
set_size
(
long
n_
,
long
k_
=
1
,
long
nr_
=
1
,
long
nc_
=
1
...
...
dlib/dnn/tensor_abstract.h
View file @
c118dcb6
...
...
@@ -412,6 +412,22 @@ namespace dlib
- #nc() == 0
!*/
template
<
typename
EXP
>
resizable_tensor
(
const
matrix_exp
<
EXP
>&
item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Assigns item to *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) = item;
!*/
explicit
resizable_tensor
(
long
n_
,
long
k_
=
1
,
long
nr_
=
1
,
long
nc_
=
1
);
...
...
@@ -470,6 +486,54 @@ namespace dlib
- #nr() == nr_
- #nc() == nc_
!*/
template
<
typename
EXP
>
resizable_tensor
&
operator
=
(
const
matrix_exp
<
EXP
>&
item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Assigns item to *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) = item;
!*/
template
<
typename
EXP
>
resizable_tensor
&
operator
+=
(
const
matrix_exp
<
EXP
>&
item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Adds item to *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) += item;
!*/
template
<
typename
EXP
>
resizable_tensor
&
operator
-=
(
const
matrix_exp
<
EXP
>&
item
);
/*!
requires
- item contains float values
ensures
- #num_samples() == item.nr()
- #k() == item.nc()
- #nr() == 1
- #nc() == 1
- Subtracts item from *this tensor by performing:
set_ptrm(host(), num_samples(), k()*nr()*nc()) -= item;
!*/
};
void
serialize
(
const
tensor
&
item
,
std
::
ostream
&
out
);
...
...
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