Skip to content

fixed typos in gui folder #1150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 204 commits into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
fe514c6
changed queue to set in AC3
dmeoli Mar 24, 2019
0129aa9
re-added test commented by mistake
dmeoli Mar 28, 2019
03551fb
added the mentioned AC4 algorithm for constraint propagation
dmeoli Apr 11, 2019
c0b8383
Merge branch 'master' into master
dmeoli Apr 11, 2019
6986247
added doctest in Sudoku for AC4 and and the possibility of choosing t…
dmeoli Apr 11, 2019
b3cd24c
removed useless doctest for AC4 in Sudoku because AC4's tests are alr…
dmeoli Apr 11, 2019
9e0fa55
added map coloring SAT problems
dmeoli Jun 17, 2019
f743146
fixed typo errors and removed unnecessary brackets
dmeoli Jun 17, 2019
20ab0e5
reformulated the map coloring problem
dmeoli Jul 4, 2019
404b179
Revert "reformulated the map coloring problem"
dmeoli Jul 4, 2019
c9c5106
Revert "fixed typo errors and removed unnecessary brackets"
dmeoli Jul 4, 2019
3243ba1
Revert "added map coloring SAT problems"
dmeoli Jul 4, 2019
2af1659
Revert "removed useless doctest for AC4 in Sudoku because AC4's tests…
dmeoli Jul 4, 2019
0c7e5af
Revert "added doctest in Sudoku for AC4 and and the possibility of ch…
dmeoli Jul 4, 2019
ff8c411
Revert "added the mentioned AC4 algorithm for constraint propagation"
dmeoli Jul 4, 2019
93af259
added map coloring SAT problem
dmeoli Jul 4, 2019
002a34e
Merge remote-tracking branch 'upstream/master'
dmeoli Jul 4, 2019
6641c2c
fixed build error
dmeoli Jul 4, 2019
9399dfc
Revert "added map coloring SAT problem"
dmeoli Jul 29, 2019
e130909
Revert "fixed build error"
dmeoli Jul 29, 2019
78bdeb1
Merge remote-tracking branch 'upstream/master'
dmeoli Jul 29, 2019
2f62776
added map coloring SAT problem
dmeoli Jul 29, 2019
aaea704
removed redundant parentheses
dmeoli Jul 29, 2019
0cd6386
Merge remote-tracking branch 'upstream/master'
dmeoli Aug 7, 2019
be656aa
added Viterbi algorithm
dmeoli Aug 14, 2019
c74933a
added monkey & bananas planning problem
dmeoli Aug 23, 2019
6d229ce
simplified condition in search.py
dmeoli Aug 23, 2019
24041e9
added tests for monkey & bananas planning problem
dmeoli Aug 23, 2019
9d37ae0
removed monkey & bananas planning problem
dmeoli Aug 23, 2019
459aae6
Revert "removed monkey & bananas planning problem"
dmeoli Aug 23, 2019
dbfb9c1
Revert "added tests for monkey & bananas planning problem"
dmeoli Aug 23, 2019
14d9014
Revert "simplified condition in search.py"
dmeoli Aug 23, 2019
5eb29cd
Revert "added monkey & bananas planning problem"
dmeoli Aug 23, 2019
396c38b
Merge remote-tracking branch 'upstream/master'
dmeoli Aug 23, 2019
776c131
defined the PlanningProblem as a specialization of a search.Problem &…
dmeoli Aug 27, 2019
ccc7de1
fixed doctest in logic.py
dmeoli Aug 27, 2019
7e98afb
fixed doctest for cascade_distribution
dmeoli Aug 27, 2019
061cba1
added ForwardPlanner and tests
dmeoli Aug 30, 2019
8c10d9f
added __lt__ implementation for Expr
dmeoli Aug 30, 2019
aa61869
added more tests
dmeoli Aug 30, 2019
c4139e5
renamed forward planner
dmeoli Aug 31, 2019
e4c4343
Revert "renamed forward planner"
dmeoli Aug 31, 2019
6e084c0
renamed forward planner class & added doc
dmeoli Aug 31, 2019
b6a0cbd
added backward planner and tests
dmeoli Sep 2, 2019
1131f4d
Merge remote-tracking branch 'upstream/master'
dmeoli Sep 3, 2019
1af8978
fixed mdp4e.py doctests
dmeoli Sep 3, 2019
a4ad133
removed ignore_delete_lists_heuristic flag
dmeoli Sep 3, 2019
26f2b5d
fixed heuristic for forward and backward planners
dmeoli Sep 6, 2019
9faf17a
added SATPlan and tests
dmeoli Sep 6, 2019
0be0f5d
fixed ignore delete lists heuristic in forward and backward planners
dmeoli Sep 7, 2019
2cc2d3f
fixed backward planner and added tests
dmeoli Sep 8, 2019
4222176
updated doc
dmeoli Sep 8, 2019
30af352
Merge remote-tracking branch 'upstream/master'
dmeoli Sep 11, 2019
b69a907
added nary csp definition and examples
dmeoli Sep 11, 2019
6ff465a
added CSPlan and tests
dmeoli Sep 11, 2019
d3c291c
fixed CSPlan
dmeoli Sep 11, 2019
785850a
added book's cryptarithmetic puzzle example
dmeoli Sep 11, 2019
7249058
fixed typo errors in test_csp
dmeoli Sep 11, 2019
42e9cbc
fixed #1111
dmeoli Sep 12, 2019
0fb48f6
added sortedcontainers to yml and doc to CSPlan
dmeoli Sep 12, 2019
5cce7d9
added tests for n-ary csp
dmeoli Sep 13, 2019
b567a6d
fixed utils.extend
dmeoli Sep 13, 2019
2eba772
updated test_probability.py
dmeoli Sep 14, 2019
427e85a
converted static methods to functions
dmeoli Sep 15, 2019
cd1ad41
added AC3b and AC4 with heuristic and tests
dmeoli Sep 15, 2019
0092f27
Merge remote-tracking branch 'upstream/master'
dmeoli Sep 16, 2019
d9dd4bb
added conflict-driven clause learning sat solver
dmeoli Sep 16, 2019
c0220d2
added tests for cdcl and heuristics
dmeoli Sep 16, 2019
8f0779d
fixed probability.py
dmeoli Sep 17, 2019
7a59010
fixed import
dmeoli Sep 17, 2019
0135db6
fixed kakuro
dmeoli Sep 20, 2019
ac98bd8
Merge remote-tracking branch 'upstream/master'
dmeoli Sep 21, 2019
dca70da
added Martelli and Montanari rule-based unification algorithm
dmeoli Sep 25, 2019
84e7a55
removed duplicate standardize_variables
dmeoli Sep 25, 2019
20bc37b
renamed variables known as built-in functions
dmeoli Sep 26, 2019
4b02d92
fixed typos in learning.py
dmeoli Sep 26, 2019
8427b5f
renamed some files and fixed typos
dmeoli Sep 26, 2019
3ffe3e9
fixed typos
dmeoli Sep 26, 2019
2d0dbc2
fixed typos
dmeoli Sep 27, 2019
b7e8206
fixed tests
dmeoli Sep 27, 2019
0c5f0ac
removed unify_mm
dmeoli Sep 29, 2019
bcc169d
remove unnecessary brackets
dmeoli Sep 29, 2019
9dd097b
fixed tests
dmeoli Sep 29, 2019
abc8f17
moved utility functions to utils.py
dmeoli Sep 29, 2019
9839d14
Merge remote-tracking branch 'upstream/master'
dmeoli Sep 29, 2019
50e036f
fixed typos
dmeoli Oct 1, 2019
44e1f9c
moved utils function to utils.py, separated probability learning clas…
dmeoli Oct 3, 2019
17285cc
added missing learners
dmeoli Oct 3, 2019
d80fed5
fixed Travis build
dmeoli Oct 3, 2019
a734d46
fixed typos
dmeoli Oct 3, 2019
df16744
fixed typos
dmeoli Oct 3, 2019
c81425f
fixed typos
dmeoli Oct 3, 2019
0071746
fixed typos
dmeoli Oct 4, 2019
25ac7b3
Merge branch 'master' into master
dmeoli Oct 4, 2019
f4f8663
fixed typos in agents files
dmeoli Oct 4, 2019
dd8ae31
fixed imports in agent files
dmeoli Oct 4, 2019
13000ac
Merge branch 'ml'
dmeoli Oct 4, 2019
b11adf4
Merge remote-tracking branch 'upstream/master'
dmeoli Oct 7, 2019
e041479
fixed deep learning .ipynb imports
dmeoli Oct 8, 2019
be7c131
fixed typos
dmeoli Oct 8, 2019
9b3c8ba
added SVM
dmeoli Oct 8, 2019
8bede28
Merge remote-tracking branch 'upstream/master'
dmeoli Oct 8, 2019
fa6676c
Merge branch 'master' into ml
dmeoli Oct 8, 2019
e0b4a1c
Merge remote-tracking branch 'upstream/master'
dmeoli Oct 24, 2019
e31a5a3
Merge branch 'master' into ml
dmeoli Oct 24, 2019
99c1b4c
Merge remote-tracking branch 'upstream/master'
dmeoli Oct 29, 2019
a672234
Merge branch 'master' into ml
dmeoli Oct 29, 2019
b9236db
added .ipynb and fixed typos
dmeoli Nov 1, 2019
3001803
adapted code for .ipynb
dmeoli Nov 1, 2019
e5f75f3
fixed typos
dmeoli Nov 1, 2019
278574d
updated .ipynb
dmeoli Nov 1, 2019
25c590d
updated .ipynb
dmeoli Nov 1, 2019
23e3d95
updated logic.py
dmeoli Nov 1, 2019
aa79be3
updated .ipynb
dmeoli Nov 1, 2019
42a6d4a
updated .ipynb
dmeoli Nov 1, 2019
ce3d0c6
updated planning.py
dmeoli Nov 1, 2019
8f5ef83
updated inf definition
dmeoli Nov 1, 2019
9d27673
fixed typos
dmeoli Nov 2, 2019
181d257
fixed typos
dmeoli Nov 2, 2019
08ad660
fixed typos
dmeoli Nov 2, 2019
658309d
fixed typos
dmeoli Nov 2, 2019
35fc24d
Revert "fixed typos"
dmeoli Nov 2, 2019
ecc7c2d
Revert "fixed typos"
dmeoli Nov 2, 2019
dbbe897
fixed typos
dmeoli Nov 2, 2019
8ef5e0c
fixed typos
dmeoli Nov 2, 2019
cf95e44
fixed typos
dmeoli Nov 2, 2019
0d64274
fixed typos
dmeoli Nov 2, 2019
3404deb
Merge branch 'master' into ml
dmeoli Nov 2, 2019
29644d4
fixed typos and utils imports in *4e.py files
dmeoli Nov 2, 2019
43f09c6
Merge branch 'master' into ml
dmeoli Nov 2, 2019
1c68b8a
Merge remote-tracking branch 'upstream/master'
dmeoli Nov 3, 2019
47df065
Merge remote-tracking branch 'upstream/master' into ml
dmeoli Nov 3, 2019
1654a9c
fixed typos
dmeoli Nov 3, 2019
fe5801e
Merge branch 'master' into ml
dmeoli Nov 3, 2019
b3d0352
Merge remote-tracking branch 'upstream/master'
dmeoli Nov 4, 2019
3960568
Merge branch 'master' into ml
dmeoli Nov 4, 2019
089d4b9
fixed typos
dmeoli Nov 4, 2019
c531100
Merge branch 'master' into ml
dmeoli Nov 4, 2019
b065c3f
fixed typos
dmeoli Nov 6, 2019
c7787cf
fixed typos
dmeoli Nov 6, 2019
e3b6a0c
Merge branch 'master' into ml
dmeoli Nov 6, 2019
d10fa04
fixed import
dmeoli Nov 10, 2019
e334940
fixed typos
dmeoli Nov 11, 2019
598a4ca
fixed typos
dmeoli Nov 11, 2019
8aeccda
fixd typos
dmeoli Nov 11, 2019
5afbf72
fixed typos
dmeoli Nov 11, 2019
182c588
fixed typos
dmeoli Nov 14, 2019
a47a516
updated SVM
dmeoli Nov 15, 2019
45cceab
added svm test
dmeoli Nov 15, 2019
86f91f9
fixed SVM and tests
dmeoli Nov 18, 2019
3f8f759
fixed some definitions and typos
dmeoli Nov 19, 2019
602627e
fixed svm and tests
dmeoli Nov 19, 2019
47c559e
added SVMs also in learning4e.py
dmeoli Nov 19, 2019
bcec266
fixed inf definition
dmeoli Nov 19, 2019
9a2541b
fixed .travis.yml
dmeoli Nov 19, 2019
2b55d16
fixed .travis.yml
dmeoli Nov 19, 2019
6143a07
fixed import
dmeoli Nov 19, 2019
bc4dd41
fixed inf definition
dmeoli Nov 19, 2019
d6f5024
replaced cvxopt with qpsolvers
dmeoli Nov 20, 2019
3473fc6
replaced cvxopt with quadprog
dmeoli Nov 20, 2019
924a4fb
fixed some definitions
dmeoli Nov 20, 2019
0044cbf
fixed typos and removed unnecessary tests
dmeoli Nov 20, 2019
75b8c2f
replaced quadprog with qpsolvers
dmeoli Nov 20, 2019
0a5fa77
fixed extend in utils
dmeoli Nov 20, 2019
132bf13
specified error type in try-catch block
dmeoli Nov 20, 2019
b81a7a6
fixed extend in utils
dmeoli Nov 20, 2019
72b5c20
fixed typos
dmeoli Nov 21, 2019
b63a622
fixed learning.py
dmeoli Nov 21, 2019
210c800
fixed doctest errors
dmeoli Nov 21, 2019
dca1c90
added comments
dmeoli Nov 21, 2019
bc4b18f
removed unnecessary if condition
dmeoli Nov 21, 2019
bd74894
updated learning.py
dmeoli Nov 22, 2019
94e81e1
fixed imports
dmeoli Nov 24, 2019
27dd36a
removed unnecessary imports
dmeoli Nov 24, 2019
8f5b1b0
fixed keras imports
dmeoli Nov 24, 2019
ede8658
fixed typos
dmeoli Nov 24, 2019
72a9040
fixed learning_curve
dmeoli Nov 30, 2019
c8a507c
added comments
dmeoli Dec 2, 2019
1b0d37c
Merge remote-tracking branch 'upstream/master'
dmeoli Dec 3, 2019
3260123
Merge remote-tracking branch 'upstream/master'
dmeoli Dec 12, 2019
83d84d7
fixed typos
dmeoli Dec 12, 2019
6b278c3
removed inf and isclose definition from utils and replaced with numpy…
dmeoli Dec 14, 2019
2847f54
fixed doctests
dmeoli Dec 14, 2019
0a8b1a9
Merge remote-tracking branch 'upstream/master'
dmeoli Dec 14, 2019
c1383d1
Merge remote-tracking branch 'upstream/master'
dmeoli Dec 19, 2019
d4b87b6
fixed numpy imports
dmeoli Jan 2, 2020
33ff87a
fixed superclass call
dmeoli Jan 2, 2020
b2f6d59
removed utils import from 4e py file
dmeoli Jan 2, 2020
d1b31da
removed unnecessary norm function in utils and fixed Activation defin…
dmeoli Jan 2, 2020
8205e43
Merge remote-tracking branch 'upstream/master'
dmeoli Jan 3, 2020
968c861
removed unnecessary clip function
dmeoli Jan 3, 2020
6584ee8
removed unnecessary import and functions from utils
dmeoli Jan 3, 2020
4de42bc
added tests and fxed some functions
dmeoli Jan 4, 2020
a3f3e39
fixed doc
dmeoli Jan 4, 2020
da5a834
Merge remote-tracking branch 'upstream/master'
dmeoli Jan 4, 2020
c97a543
fixed typos in gui folder
dmeoli Jan 8, 2020
1bfa61b
Merge remote-tracking branch 'upstream/master'
dmeoli Jan 8, 2020
f795d6f
removed unnecessary Keras classes and updated pytest.ini
dmeoli Jan 24, 2020
d229c23
Merge remote-tracking branch 'upstream/master'
dmeoli Jan 24, 2020
d9a67f7
fixed some details
dmeoli Jan 24, 2020
09262c9
readded Keras classes
dmeoli Jan 24, 2020
716459e
fixed import
dmeoli Jan 24, 2020
64f1cd3
fixed some parameters
dmeoli Jan 24, 2020
53ec4e2
removed unnecessary superclass
dmeoli Jan 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 21 additions & 39 deletions deep_learning4e.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,14 @@


class Node:
"""
A node in a computational graph contains the pointer to all its parents.
:param val: value of current node
:param parents: a container of all parents of current node
"""

def __init__(self, val=None, parents=None):
if parents is None:
parents = []
self.val = val
self.parents = parents

def __repr__(self):
return "<Node {}>".format(self.val)


class NNUnit(Node):
"""
A single unit of a layer in a neural network
:param weights: weights between parent nodes and current node
:param value: value of current node
"""

def __init__(self, weights=None, value=None):
super().__init__(value)
self.value = value
self.weights = weights or []


Expand All @@ -47,8 +30,8 @@ class Layer:
:param size: number of units in the current layer
"""

def __init__(self, size=3):
self.nodes = [NNUnit() for _ in range(size)]
def __init__(self, size):
self.nodes = [Node() for _ in range(size)]

def forward(self, inputs):
"""Define the operation to get the output of this layer"""
Expand All @@ -65,7 +48,7 @@ def forward(self, inputs):
"""Take each value of the inputs to each unit in the layer."""
assert len(self.nodes) == len(inputs)
for node, inp in zip(self.nodes, inputs):
node.val = inp
node.value = inp
return inputs


Expand All @@ -79,7 +62,7 @@ def forward(self, inputs):
assert len(self.nodes) == len(inputs)
res = softmax1D(inputs)
for node, val in zip(self.nodes, res):
node.val = val
node.value = val
return res


Expand All @@ -91,11 +74,11 @@ class DenseLayer(Layer):
:param activation: (Activation object) activation function
"""

def __init__(self, in_size=3, out_size=3, activation=None):
def __init__(self, in_size=3, out_size=3, activation=Sigmoid):
super().__init__(out_size)
self.out_size = out_size
self.inputs = None
self.activation = Sigmoid() if not activation else activation
self.activation = activation()
# initialize weights
for node in self.nodes:
node.weights = random_weights(-0.5, 0.5, in_size)
Expand All @@ -105,8 +88,8 @@ def forward(self, inputs):
res = []
# get the output value of each unit
for unit in self.nodes:
val = self.activation.f(dot_product(unit.weights, inputs))
unit.val = val
val = self.activation.function(dot_product(unit.weights, inputs))
unit.value = val
res.append(val)
return res

Expand All @@ -131,7 +114,7 @@ def forward(self, features):
for node, feature in zip(self.nodes, features):
out = conv1D(feature, node.weights)
res.append(out)
node.val = out
node.value = out
return res


Expand All @@ -157,7 +140,7 @@ def forward(self, features):
out = [max(feature[i:i + self.kernel_size])
for i in range(len(feature) - self.kernel_size + 1)]
res.append(out)
self.nodes[i].val = out
self.nodes[i].value = out
return res


Expand All @@ -181,7 +164,7 @@ def init_examples(examples, idx_i, idx_t, o_units):
return inputs, targets


def gradient_descent(dataset, net, loss, epochs=1000, l_rate=0.01, batch_size=1, verbose=None):
def stochastic_gradient_descent(dataset, net, loss, epochs=1000, l_rate=0.01, batch_size=1, verbose=None):
"""
Gradient descent algorithm to update the learnable parameters of a network.
:return: the updated network
Expand All @@ -200,6 +183,7 @@ def gradient_descent(dataset, net, loss, epochs=1000, l_rate=0.01, batch_size=1,
# update weights with gradient descent
weights = vector_add(weights, scalar_vector_product(-l_rate, gs))
total_loss += batch_loss

# update the weights of network each batch
for i in range(len(net)):
if weights[i]:
Expand Down Expand Up @@ -310,7 +294,7 @@ def BackPropagation(inputs, targets, theta, net, loss):
# backward pass
for i in range(h_layers, 0, -1):
layer = net[i]
derivative = [layer.activation.derivative(node.val) for node in layer.nodes]
derivative = [layer.activation.derivative(node.value) for node in layer.nodes]
delta[i] = element_wise_product(previous, derivative)
# pass to layer i-1 in the next iteration
previous = matrix_multiplication([delta[i]], theta[i])[0]
Expand Down Expand Up @@ -344,7 +328,7 @@ def forward(self, inputs):
for i in range(len(self.nodes)):
val = [(inputs[i] - mu) * self.weights[0] / np.sqrt(self.eps + stderr ** 2) + self.weights[1]]
res.append(val)
self.nodes[i].val = val
self.nodes[i].value = val
return res


Expand All @@ -354,15 +338,12 @@ def get_batch(examples, batch_size=1):
yield examples[i: i + batch_size]


def NeuralNetLearner(dataset, hidden_layer_sizes=None, learning_rate=0.01, epochs=100,
optimizer=gradient_descent, batch_size=1, verbose=None):
def NeuralNetLearner(dataset, hidden_layer_sizes, l_rate=0.01, epochs=1000, batch_size=1,
optimizer=stochastic_gradient_descent, verbose=None):
"""
Simple dense multilayer neural network.
:param hidden_layer_sizes: size of hidden layers in the form of a list
"""

if hidden_layer_sizes is None:
hidden_layer_sizes = [4]
input_size = len(dataset.inputs)
output_size = len(dataset.values[dataset.target])

Expand All @@ -376,7 +357,7 @@ def NeuralNetLearner(dataset, hidden_layer_sizes=None, learning_rate=0.01, epoch
raw_net.append(DenseLayer(hidden_input_size, output_size))

# update parameters of the network
learned_net = optimizer(dataset, raw_net, mean_squared_error_loss, epochs, l_rate=learning_rate,
learned_net = optimizer(dataset, raw_net, mean_squared_error_loss, epochs, l_rate=l_rate,
batch_size=batch_size, verbose=verbose)

def predict(example):
Expand All @@ -395,7 +376,8 @@ def predict(example):
return predict


def PerceptronLearner(dataset, learning_rate=0.01, epochs=100, optimizer=gradient_descent, batch_size=1, verbose=None):
def PerceptronLearner(dataset, l_rate=0.01, epochs=1000, batch_size=1,
optimizer=stochastic_gradient_descent, verbose=None):
"""
Simple perceptron neural network.
"""
Expand All @@ -406,7 +388,7 @@ def PerceptronLearner(dataset, learning_rate=0.01, epochs=100, optimizer=gradien
raw_net = [InputLayer(input_size), DenseLayer(input_size, output_size)]

# update the network
learned_net = optimizer(dataset, raw_net, mean_squared_error_loss, epochs, l_rate=learning_rate,
learned_net = optimizer(dataset, raw_net, mean_squared_error_loss, epochs, l_rate=l_rate,
batch_size=batch_size, verbose=verbose)

def predict(example):
Expand Down
Loading