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
ModelZoo
ResNet50_tensorflow
Commits
b13d6e51
Commit
b13d6e51
authored
Jul 27, 2017
by
Dan O'Shea
Browse files
LFADS: Fixing alignment bias bug
parent
7dde2e2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
lfads/lfads.py
lfads/lfads.py
+9
-3
lfads/utils.py
lfads/utils.py
+1
-1
No files found.
lfads/lfads.py
View file @
b13d6e51
...
@@ -281,7 +281,7 @@ class LFADS(object):
...
@@ -281,7 +281,7 @@ class LFADS(object):
"""Create an LFADS model.
"""Create an LFADS model.
train - a model for training, sampling of posteriors is used
train - a model for training, sampling of posteriors is used
posterior_sample_and_average - sample from the posterior, this is used
posterior_sample_and_average - sample from the posterior, this is used
for evaluating the expected value of the outputs of LFADS, given a
for evaluating the expected value of the outputs of LFADS, given a
specific input, by averaging over multiple samples from the approx
specific input, by averaging over multiple samples from the approx
posterior. Also used for the lower bound on the negative
posterior. Also used for the lower bound on the negative
...
@@ -409,6 +409,12 @@ class LFADS(object):
...
@@ -409,6 +409,12 @@ class LFADS(object):
dataset
=
datasets
[
name
]
dataset
=
datasets
[
name
]
in_mat_cxf
=
dataset
[
'alignment_matrix_cxf'
].
astype
(
np
.
float32
)
in_mat_cxf
=
dataset
[
'alignment_matrix_cxf'
].
astype
(
np
.
float32
)
if
datasets
and
'alignment_bias_c'
in
datasets
[
name
].
keys
():
dataset
=
datasets
[
name
]
print
(
"Using alignment bias provided for dataset:"
,
name
)
align_bias_c
=
dataset
[
'alignment_bias_c'
].
astype
(
np
.
float32
)
align_bias_1xc
=
np
.
expand_dims
(
align_bias_c
,
axis
=
0
)
out_mat_fxc
=
None
out_mat_fxc
=
None
out_bias_1xc
=
None
out_bias_1xc
=
None
if
in_mat_cxf
is
not
None
:
if
in_mat_cxf
is
not
None
:
...
@@ -1714,7 +1720,7 @@ class LFADS(object):
...
@@ -1714,7 +1720,7 @@ class LFADS(object):
out_dist_params
=
np
.
zeros
([
E_to_process
,
T
,
D
+
D
])
out_dist_params
=
np
.
zeros
([
E_to_process
,
T
,
D
+
D
])
else
:
else
:
assert
False
,
"NIY"
assert
False
,
"NIY"
costs
=
np
.
zeros
(
E_to_process
)
costs
=
np
.
zeros
(
E_to_process
)
nll_bound_vaes
=
np
.
zeros
(
E_to_process
)
nll_bound_vaes
=
np
.
zeros
(
E_to_process
)
nll_bound_iwaes
=
np
.
zeros
(
E_to_process
)
nll_bound_iwaes
=
np
.
zeros
(
E_to_process
)
...
@@ -1914,7 +1920,7 @@ class LFADS(object):
...
@@ -1914,7 +1920,7 @@ class LFADS(object):
for
i
,
(
var
,
var_eval
)
in
enumerate
(
zip
(
all_tf_vars
,
all_tf_vars_eval
)):
for
i
,
(
var
,
var_eval
)
in
enumerate
(
zip
(
all_tf_vars
,
all_tf_vars_eval
)):
if
any
(
s
in
include_strs
for
s
in
var
.
name
):
if
any
(
s
in
include_strs
for
s
in
var
.
name
):
if
not
isinstance
(
var_eval
,
np
.
ndarray
):
# for H5PY
if
not
isinstance
(
var_eval
,
np
.
ndarray
):
# for H5PY
print
(
var
.
name
,
""" is not numpy array, saving as numpy array
print
(
var
.
name
,
""" is not numpy array, saving as numpy array
with value: """
,
var_eval
,
type
(
var_eval
))
with value: """
,
var_eval
,
type
(
var_eval
))
e
=
np
.
array
(
var_eval
)
e
=
np
.
array
(
var_eval
)
print
(
e
,
type
(
e
))
print
(
e
,
type
(
e
))
...
...
lfads/utils.py
View file @
b13d6e51
...
@@ -112,7 +112,7 @@ def init_linear(in_size, out_size, do_bias=True, mat_init_value=None,
...
@@ -112,7 +112,7 @@ def init_linear(in_size, out_size, do_bias=True, mat_init_value=None,
'Provided mat_init_value must have shape [%d, %d].'
%
(
in_size
,
out_size
))
'Provided mat_init_value must have shape [%d, %d].'
%
(
in_size
,
out_size
))
if
bias_init_value
is
not
None
and
bias_init_value
.
shape
!=
(
1
,
out_size
):
if
bias_init_value
is
not
None
and
bias_init_value
.
shape
!=
(
1
,
out_size
):
raise
ValueError
(
raise
ValueError
(
'Provided bias_init_value must have shape [1,%d].'
%
(
1
,
out_size
))
'Provided bias_init_value must have shape [1,%d].'
%
(
out_size
,
))
if
mat_init_value
is
None
:
if
mat_init_value
is
None
:
stddev
=
alpha
/
np
.
sqrt
(
float
(
in_size
))
stddev
=
alpha
/
np
.
sqrt
(
float
(
in_size
))
...
...
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