public abstract class Vertex<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.concurrent.atomic.AtomicLong |
ID_GENERATOR |
Constructor and Description |
---|
Vertex() |
Modifier and Type | Method and Description |
---|---|
void |
addChild(Vertex<?> v) |
void |
addParent(Vertex<?> parent) |
void |
addParents(java.util.Collection<? extends Vertex> parents) |
abstract java.util.Map<java.lang.Long,DoubleTensor> |
dLogProb(T value)
The partial derivatives of the natural log prob.
|
java.util.Map<java.lang.Long,DoubleTensor> |
dLogProbAtValue() |
boolean |
equals(java.lang.Object o) |
T |
eval()
This causes a backwards propagating calculation of the vertex value.
|
java.util.Set<Vertex> |
getChildren() |
java.util.Set<Vertex> |
getConnectedGraph() |
long |
getId() |
java.util.Set<Vertex> |
getParents() |
protected T |
getRawValue() |
int[] |
getShape() |
T |
getValue() |
int |
hashCode() |
boolean |
hasValue() |
boolean |
isObserved() |
abstract boolean |
isProbabilistic() |
T |
lazyEval()
This is similar to eval() except it only propagates as far up the graph as required until
there are values present to operate on.
|
abstract double |
logProb(T value)
This is the natural log of the probability at the supplied value.
|
double |
logProbAtValue() |
void |
observe(T value)
This marks the vertex's value as being observed and unchangeable.
|
void |
observeOwnValue()
Cause this vertex to observe its own value, for example when generating test data
|
T |
sample() |
abstract T |
sample(KeanuRandom random) |
void |
setAndCascade(T value)
This sets the value in this vertex and tells each child vertex about
the new change.
|
void |
setParents(java.util.Collection<? extends Vertex> parents) |
void |
setParents(Vertex<?>... parents) |
void |
setValue(T value)
Sets the value if the vertex isn't already observed.
|
void |
unobserve() |
abstract T |
updateValue()
This causes a non-probabilistic vertex to recalculate it's value based off it's
parent's current values.
|
public abstract double logProb(T value)
value
- The supplied value.public double logProbAtValue()
public abstract java.util.Map<java.lang.Long,DoubleTensor> dLogProb(T value)
value
- at a given valuepublic final java.util.Map<java.lang.Long,DoubleTensor> dLogProbAtValue()
public abstract T sample(KeanuRandom random)
random
- source of randomnesspublic T sample()
public abstract T updateValue()
public final T lazyEval()
public final T eval()
public abstract boolean isProbabilistic()
public void setValue(T value)
value
- the observed valuepublic T getValue()
protected T getRawValue()
public boolean hasValue()
public int[] getShape()
public void setAndCascade(T value)
value
- The new value at this vertexpublic void observe(T value)
Non-probabilistic vertices of continuous types (integer, double) are prohibited from being observed due to it's negative impact on inference algorithms. Non-probabilistic booleans are allowed to be observed as well as user defined types.
value
- the value to be observedpublic void observeOwnValue()
public void unobserve()
public boolean isObserved()
public long getId()
public java.util.Set<Vertex> getChildren()
public void addChild(Vertex<?> v)
public void setParents(java.util.Collection<? extends Vertex> parents)
public void setParents(Vertex<?>... parents)
public void addParents(java.util.Collection<? extends Vertex> parents)
public void addParent(Vertex<?> parent)
public java.util.Set<Vertex> getParents()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.util.Set<Vertex> getConnectedGraph()