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
8f3e8a6c
Commit
8f3e8a6c
authored
Jun 11, 2016
by
Davis King
Browse files
Made mat() work on empty tensors.
parent
dd8bf755
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
dlib/dnn/tensor.h
dlib/dnn/tensor.h
+6
-8
dlib/dnn/tensor_abstract.h
dlib/dnn/tensor_abstract.h
+6
-5
No files found.
dlib/dnn/tensor.h
View file @
8f3e8a6c
...
@@ -192,9 +192,9 @@ namespace dlib
...
@@ -192,9 +192,9 @@ namespace dlib
long
nc
long
nc
)
)
{
{
DLIB_ASSERT
(
nr
>
0
&&
nc
>
0
,
DLIB_ASSERT
(
nr
>
=
0
&&
nc
>
=
0
,
"
\t
const matrix_exp mat(tensor, nr, nc)"
"
\t
const matrix_exp mat(tensor, nr, nc)"
<<
"
\n\t
nr and nc must be
bigger than
0"
<<
"
\n\t
nr and nc must be
>=
0"
<<
"
\n\t
nr: "
<<
nr
<<
"
\n\t
nr: "
<<
nr
<<
"
\n\t
nc: "
<<
nc
<<
"
\n\t
nc: "
<<
nc
);
);
...
@@ -212,12 +212,10 @@ namespace dlib
...
@@ -212,12 +212,10 @@ namespace dlib
const
tensor
&
t
const
tensor
&
t
)
)
{
{
DLIB_ASSERT
(
t
.
size
()
!=
0
,
if
(
t
.
size
()
!=
0
)
"
\t
const matrix_exp mat(tensor)"
return
mat
(
t
,
t
.
num_samples
(),
t
.
size
()
/
t
.
num_samples
());
<<
"
\n\t
The tensor can't be empty."
else
);
return
mat
((
float
*
)
0
,
0
,
0
);
return
mat
(
t
,
t
.
num_samples
(),
t
.
size
()
/
t
.
num_samples
());
}
}
inline
const
matrix_op
<
op_pointer_to_mat
<
float
>
>
image_plane
(
inline
const
matrix_op
<
op_pointer_to_mat
<
float
>
>
image_plane
(
...
...
dlib/dnn/tensor_abstract.h
View file @
8f3e8a6c
...
@@ -333,8 +333,8 @@ namespace dlib
...
@@ -333,8 +333,8 @@ namespace dlib
);
);
/*!
/*!
requires
requires
- nr > 0
- nr >
=
0
- nc > 0
- nc >
=
0
- nr*nc == t.size()
- nr*nc == t.size()
ensures
ensures
- returns a matrix M such that:
- returns a matrix M such that:
...
@@ -350,10 +350,11 @@ namespace dlib
...
@@ -350,10 +350,11 @@ namespace dlib
const
tensor
&
t
const
tensor
&
t
);
);
/*!
/*!
requires
- t.size() != 0
ensures
ensures
- returns mat(t, t.num_samples(), t.size()/t.num_samples())
- if (t.size() != 0) then
- returns mat(t, t.num_samples(), t.size()/t.num_samples())
- else
- returns an empty matrix.
!*/
!*/
const
matrix_exp
image_plane
(
const
matrix_exp
image_plane
(
...
...
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