Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PRIMO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
PRIMO
Commits
a73b004b
Commit
a73b004b
authored
12 years ago
by
Denis John PC
Browse files
Options
Downloads
Patches
Plain Diff
multiplication started
parent
ade81d3c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
primo/reasoning/density/ProbabilityTable.py
+41
-2
41 additions, 2 deletions
primo/reasoning/density/ProbabilityTable.py
with
41 additions
and
2 deletions
primo/reasoning/density/ProbabilityTable.py
+
41
−
2
View file @
a73b004b
...
@@ -64,8 +64,47 @@ class ProbabilityTable(Density):
...
@@ -64,8 +64,47 @@ class ProbabilityTable(Density):
def
is_normalized_as_jpt
(
self
):
def
is_normalized_as_jpt
(
self
):
return
numpy
.
sum
(
table
)
==
1.0
return
numpy
.
sum
(
table
)
==
1.0
def
multiplication
(
self
,
factor
):
def
multiplication
(
self
,
inputFactor
):
raise
Exception
(
"
Called unimplemented function
"
)
raise
Exception
(
"
Called unimplemented function
"
)
#init a new probability tabel
factor1
=
ProbabilityTable
()
#all variables from both factors are needed
factor1
.
variables
=
copy
.
copy
(
self
.
variables
)
for
v
in
factor
.
variables
:
if
not
v
in
factor1
.
variables
:
factor1
.
variables
.
append
(
v
)
#the table from the first factor is copied
factor1
.
table
=
copy
.
copy
(
self
.
table
)
#and extended by the dimensions for the left variables
for
curIdx
in
range
(
factor1
.
table
.
ndim
,
len
(
factor1
.
variables
)):
ax
=
factor1
.
table
.
ndim
factor1
.
table
=
numpy
.
expand_dims
(
factor1
.
table
,
ax
)
factor1
.
table
=
numpy
.
repeat
(
factor1
.
table
,
len
(
factor1
.
variables
[
curIdx
].
values
),
axis
=
ax
)
#copy factor 2 and it's variables ...
factor2
=
ProbabilityTable
()
factor2
.
variables
=
copy
.
copy
(
inputFactor
.
variables
)
factor2
.
table
=
copy
.
copy
(
inputFactor
.
table
)
#extend the dimensions of factors 2 to the dimensions of factor 1
for
v
in
factor1
.
variables
:
if
not
v
in
factor2
.
variables
:
factor2
.
variables
.
append
(
v
)
for
curIdx
in
range
(
factor2
.
table
.
ndim
,
len
(
factor2
.
variables
)):
ax
=
factor2
.
table
.
ndim
factor2
.
table
=
numpy
.
expand_dims
(
factor2
.
table
,
ax
)
factor2
.
table
=
numpy
.
repeat
(
factor2
.
table
,
len
(
factor2
.
variables
[
curIdx
].
values
),
axis
=
ax
)
#sort the variables to the same order
#pointwise multiplication
def
marginalization
(
self
,
variable
):
def
marginalization
(
self
,
variable
):
raise
Exception
(
"
Called unimplemented function
"
)
raise
Exception
(
"
Called unimplemented function
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment