Git Product home page Git Product logo

eriklindernoren / ml-from-scratch Goto Github PK

View Code? Open in Web Editor NEW
23.1K 937.0 4.5K 553 KB

Machine Learning From Scratch. Bare bones NumPy implementations of machine learning models and algorithms with a focus on accessibility. Aims to cover everything from linear regression to deep learning.

License: MIT License

Python 100.00%
machine-learning deep-learning deep-reinforcement-learning machine-learning-from-scratch data-science data-mining genetic-algorithm

ml-from-scratch's Introduction

Machine Learning From Scratch

About

Python implementations of some of the fundamental Machine Learning models and algorithms from scratch.

The purpose of this project is not to produce as optimized and computationally efficient algorithms as possible but rather to present the inner workings of them in a transparent and accessible way.

Table of Contents

Installation

$ git clone https://github.com/eriklindernoren/ML-From-Scratch
$ cd ML-From-Scratch
$ python setup.py install

Examples

Polynomial Regression

$ python mlfromscratch/examples/polynomial_regression.py

Figure: Training progress of a regularized polynomial regression model fitting
temperature data measured in Linköping, Sweden 2016.

Classification With CNN

$ python mlfromscratch/examples/convolutional_neural_network.py

+---------+
| ConvNet |
+---------+
Input Shape: (1, 8, 8)
+----------------------+------------+--------------+
| Layer Type           | Parameters | Output Shape |
+----------------------+------------+--------------+
| Conv2D               | 160        | (16, 8, 8)   |
| Activation (ReLU)    | 0          | (16, 8, 8)   |
| Dropout              | 0          | (16, 8, 8)   |
| BatchNormalization   | 2048       | (16, 8, 8)   |
| Conv2D               | 4640       | (32, 8, 8)   |
| Activation (ReLU)    | 0          | (32, 8, 8)   |
| Dropout              | 0          | (32, 8, 8)   |
| BatchNormalization   | 4096       | (32, 8, 8)   |
| Flatten              | 0          | (2048,)      |
| Dense                | 524544     | (256,)       |
| Activation (ReLU)    | 0          | (256,)       |
| Dropout              | 0          | (256,)       |
| BatchNormalization   | 512        | (256,)       |
| Dense                | 2570       | (10,)        |
| Activation (Softmax) | 0          | (10,)        |
+----------------------+------------+--------------+
Total Parameters: 538570

Training: 100% [------------------------------------------------------------------------] Time: 0:01:55
Accuracy: 0.987465181058

Figure: Classification of the digit dataset using CNN.

Density-Based Clustering

$ python mlfromscratch/examples/dbscan.py

Figure: Clustering of the moons dataset using DBSCAN.

Generating Handwritten Digits

$ python mlfromscratch/unsupervised_learning/generative_adversarial_network.py

+-----------+
| Generator |
+-----------+
Input Shape: (100,)
+------------------------+------------+--------------+
| Layer Type             | Parameters | Output Shape |
+------------------------+------------+--------------+
| Dense                  | 25856      | (256,)       |
| Activation (LeakyReLU) | 0          | (256,)       |
| BatchNormalization     | 512        | (256,)       |
| Dense                  | 131584     | (512,)       |
| Activation (LeakyReLU) | 0          | (512,)       |
| BatchNormalization     | 1024       | (512,)       |
| Dense                  | 525312     | (1024,)      |
| Activation (LeakyReLU) | 0          | (1024,)      |
| BatchNormalization     | 2048       | (1024,)      |
| Dense                  | 803600     | (784,)       |
| Activation (TanH)      | 0          | (784,)       |
+------------------------+------------+--------------+
Total Parameters: 1489936

+---------------+
| Discriminator |
+---------------+
Input Shape: (784,)
+------------------------+------------+--------------+
| Layer Type             | Parameters | Output Shape |
+------------------------+------------+--------------+
| Dense                  | 401920     | (512,)       |
| Activation (LeakyReLU) | 0          | (512,)       |
| Dropout                | 0          | (512,)       |
| Dense                  | 131328     | (256,)       |
| Activation (LeakyReLU) | 0          | (256,)       |
| Dropout                | 0          | (256,)       |
| Dense                  | 514        | (2,)         |
| Activation (Softmax)   | 0          | (2,)         |
+------------------------+------------+--------------+
Total Parameters: 533762

Figure: Training progress of a Generative Adversarial Network generating
handwritten digits.

Deep Reinforcement Learning

$ python mlfromscratch/examples/deep_q_network.py

+----------------+
| Deep Q-Network |
+----------------+
Input Shape: (4,)
+-------------------+------------+--------------+
| Layer Type        | Parameters | Output Shape |
+-------------------+------------+--------------+
| Dense             | 320        | (64,)        |
| Activation (ReLU) | 0          | (64,)        |
| Dense             | 130        | (2,)         |
+-------------------+------------+--------------+
Total Parameters: 450

Figure: Deep Q-Network solution to the CartPole-v1 environment in OpenAI gym.

Image Reconstruction With RBM

$ python mlfromscratch/examples/restricted_boltzmann_machine.py

Figure: Shows how the network gets better during training at reconstructing
the digit 2 in the MNIST dataset.

Evolutionary Evolved Neural Network

$ python mlfromscratch/examples/neuroevolution.py

+---------------+
| Model Summary |
+---------------+
Input Shape: (64,)
+----------------------+------------+--------------+
| Layer Type           | Parameters | Output Shape |
+----------------------+------------+--------------+
| Dense                | 1040       | (16,)        |
| Activation (ReLU)    | 0          | (16,)        |
| Dense                | 170        | (10,)        |
| Activation (Softmax) | 0          | (10,)        |
+----------------------+------------+--------------+
Total Parameters: 1210

Population Size: 100
Generations: 3000
Mutation Rate: 0.01

[0 Best Individual - Fitness: 3.08301, Accuracy: 10.5%]
[1 Best Individual - Fitness: 3.08746, Accuracy: 12.0%]
...
[2999 Best Individual - Fitness: 94.08513, Accuracy: 98.5%]
Test set accuracy: 96.7%

Figure: Classification of the digit dataset by a neural network which has
been evolutionary evolved.

Genetic Algorithm

$ python mlfromscratch/examples/genetic_algorithm.py

+--------+
|   GA   |
+--------+
Description: Implementation of a Genetic Algorithm which aims to produce
the user specified target string. This implementation calculates each
candidate's fitness based on the alphabetical distance between the candidate
and the target. A candidate is selected as a parent with probabilities proportional
to the candidate's fitness. Reproduction is implemented as a single-point
crossover between pairs of parents. Mutation is done by randomly assigning
new characters with uniform probability.

Parameters
----------
Target String: 'Genetic Algorithm'
Population Size: 100
Mutation Rate: 0.05

[0 Closest Candidate: 'CJqlJguPlqzvpoJmb', Fitness: 0.00]
[1 Closest Candidate: 'MCxZxdr nlfiwwGEk', Fitness: 0.01]
[2 Closest Candidate: 'MCxZxdm nlfiwwGcx', Fitness: 0.01]
[3 Closest Candidate: 'SmdsAklMHn kBIwKn', Fitness: 0.01]
[4 Closest Candidate: '  lotneaJOasWfu Z', Fitness: 0.01]
...
[292 Closest Candidate: 'GeneticaAlgorithm', Fitness: 1.00]
[293 Closest Candidate: 'GeneticaAlgorithm', Fitness: 1.00]
[294 Answer: 'Genetic Algorithm']

Association Analysis

$ python mlfromscratch/examples/apriori.py
+-------------+
|   Apriori   |
+-------------+
Minimum Support: 0.25
Minimum Confidence: 0.8
Transactions:
    [1, 2, 3, 4]
    [1, 2, 4]
    [1, 2]
    [2, 3, 4]
    [2, 3]
    [3, 4]
    [2, 4]
Frequent Itemsets:
    [1, 2, 3, 4, [1, 2], [1, 4], [2, 3], [2, 4], [3, 4], [1, 2, 4], [2, 3, 4]]
Rules:
    1 -> 2 (support: 0.43, confidence: 1.0)
    4 -> 2 (support: 0.57, confidence: 0.8)
    [1, 4] -> 2 (support: 0.29, confidence: 1.0)

Implementations

Supervised Learning

Unsupervised Learning

Reinforcement Learning

Deep Learning

Contact

If there's some implementation you would like to see here or if you're just feeling social, feel free to email me or connect with me on LinkedIn.

ml-from-scratch's People

Contributors

dandilionlau avatar daviddwlee84 avatar eriklindernoren avatar miku avatar tvturnhout avatar vuong-ts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ml-from-scratch's Issues

W0 in Linear Discriminant analyis

When you take the threshold while predicting y, you did not account for the w0 terms in your equation. Hence, it always predicts y as 1, because h is always negative.
The equation should be something like this.

screen shot 2018-02-07 at 10 00 04 pm 1

Apriori - Subset name error

Name subset missing s (subsets) at line 158?

NameError Traceback (most recent call last)
in ()
17
18 # Get and print the rules
---> 19 rules = apriori.generate_rules(transactions)
20 print ("Rules:")
21 for rule in rules:

in generate_rules(self, transactions)
167 rules = []
168 for itemset in frequent_itemsets:
--> 169 rules += self._rules_from_itemset(itemset, itemset)
170 return rules

in _rules_from_itemset(self, initial_itemset, itemset)
156 # recursively add rules from subsets
157 if k - 1 > 1:
--> 158 rules.append(self._rules_from_itemset(initial_itemset, subset))
159 return rules
160

NameError: name 'subset' is not defined

Is there any special instructions to install it in windows?

I have been trying to install it on windows 10 because it looks very cool for extra learning material, but
I have not been able to install it so far. I tried to install vs build tools as the requirements said but without luck. Any ideas or suggestions?

Moore-Penrose pseudo-inverse in linear regression

Hi, I am reimplementing ml algorithms based on yours

But I am a little confused about the part of the calculation of Moore-Penrose pseudoinverse in linear regression.

U, S, V = np.linalg.svd(X.T.dot(X))
S = np.diag(S)
X_sq_reg_inv = V.dot(np.linalg.pinv(S)).dot(U.T)
self.w = X_sq_reg_inv.dot(X.T).dot(y)

Why do not usenp.linalg.pinv(X), according to the docstring:

image

It can compute the Moore-Penrose pseudo-inverse directly.

Thanks!

issues when we set up Pooling layer in CNN

clf.add(Conv2D(n_filters=16, filter_shape=(3,3), input_shape=(1,8,8), padding='same'))
clf.add(Activation('relu'))
clf.add(MaxPooling2D(pool_shape=(2, 2), stride=2))
clf.add(BatchNormalization())
clf.add(Dropout(0.25))
clf.add(Conv2D(n_filters=32, filter_shape=(3,3), padding='same'))
clf.add(Activation('relu'))
clf.add(Dropout(0.25))
clf.add(BatchNormalization())
clf.add(Flatten())
clf.add(Dense(256))
clf.add(Activation('relu'))
clf.add(Dropout(0.4))
clf.add(BatchNormalization())
clf.add(Dense(10))
clf.add(Activation('softmax'))

When we add one more pooling layer to CNN, bug appears

Traceback (most recent call last): ] ETA: --:--:--
File "convolutional_neural_network.py", line 85, in
main()
File "convolutional_neural_network.py", line 71, in main
train_err, val_err = clf.fit(X_train, y_train, n_epochs=50, batch_size=256)
File "/home/deng106/ML-From-Scratch/mlfromscratch/deep_learning/neural_network.py", line 79, in fit
loss, _ = self.train_on_batch(X_batch, y_batch)
File "/home/deng106/ML-From-Scratch/mlfromscratch/deep_learning/neural_network.py", line 63, in train_on_batch
y_pred = self._forward_pass(X)
File "/home/deng106/ML-From-Scratch/mlfromscratch/deep_learning/neural_network.py", line 94, in _forward_pass
layer_output = layer.forward_pass(layer_output, training)
File "/home/deng106/ML-From-Scratch/mlfromscratch/deep_learning/layers.py", line 380, in forward_pass
X_col = image_to_column(X, self.pool_shape, self.stride, self.padding)
File "/home/deng106/ML-From-Scratch/mlfromscratch/deep_learning/layers.py", line 696, in image_to_column
pad_h, pad_w = determine_padding(filter_shape, output_shape)
TypeError: 'NoneType' object is not iterable

It turns out output_shape=0 appears for determine_padding(filter_shape, output_shape="same").

waiting for your answer. Appreciate that.

linear regression

grad_w = -(y - y_pred).dot(X) + self.regularization.grad(self.w)

in regression.py

should it be grad_w = -(y - y_pred).dot(X) * (1/training_size) + self.regularization.grad(self.w) ?

naive_bayes

in the navie bayes , X refer to Gaussian probability distribution, why?

because you define X is continuous,?

thanks

Installation on Windows throws an error

Installation is complete but it throws this error multiple times during installation.

appdata\local\programs\python\python36\lib\site-packages\setuptools\pep425tags.py:89: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be
incorrect
  warn=(impl == 'cp')):

dbscan

What's purpose of 60~64 lines of code? I think can omit it, and you?

Why the classifiers are the same in adaboost?

I have following questions about adaboost implementation

  • Why the classifiers are the same in the end?
  • Why concatenate y_pred in predict function?

Though the accuracy of classification has no problem, I think the implementation is wrong.

mlfromscratch/supervised_learning/__init__.py has references to undefined python files.

Everything you need to know is in the title. mlfromscratch/supervised_learning/__init__.py has references to undefined python files.

To reproduce, run: "python demo.py", you get:

ImportError: No module named linear_regression

Because supervisedLearning/__init__.py has references to regression classes in files that don't exist.

I was able to correct them in my fork and rebuild and all is well, just have to rename the "whatever_regression" to regression and do the setup again.

Thinking it over, these may be intentional as an exercise for the user. Good job. 🥇

Data normalization etc.

Hi,
I see that there is no implementation for normalization, scaling etc. of the data. Can I implement that with a new pull request?

progressbar is not python3 compatible

Hi Great compilation

but progressbar has not yet been updated to python3 on pypi, but you can install master:
pip install https://github.com/datalad/python-progressbar/archive/master.zip

Add Gaussian Process

Pretty cool project. Gaussian Process might be something you can add in the future.

Apriori - Zero Division Error

After adding s to subsets (previous issue) I'm getting the list of frequent itemsets but no rules. Intentionally set my support very low to see if I could get a 2-itemset antecedent, roughly 2%. Not an issue with greater support.

ZeroDivisionError Traceback (most recent call last)
in ()
17
18 # Get and print the rules
---> 19 rules = apriori.generate_rules(transactions)
20 print ("Rules:")
21 for rule in rules:

in generate_rules(self, transactions)
167 rules = []
168 for itemset in frequent_itemsets:
--> 169 rules += self._rules_from_itemset(itemset, itemset)
170 return rules

in _rules_from_itemset(self, initial_itemset, itemset)
156 # recursively add rules from subsets
157 if k - 1 > 1:
--> 158 rules.append(self._rules_from_itemset(initial_itemset, subsets))
159 return rules
160

in _rules_from_itemset(self, initial_itemset, itemset)
136 # Calculate the confidence as sup(A and B) / sup(B), if antecedent
137 # is B in an itemset of A and B
--> 138 confidence = float("{0:.2f}".format(support / antecedent_support))
139 if confidence >= self.min_conf:
140 # The concequent is the initial_itemset except for antecedent

ZeroDivisionError: float division by zero

Demo.py AttributeError: no attribute 'solvers'

`Traceback (most recent call last):
  File "demo.py", line 23, in <module>
    from support_vector_machine import SupportVectorMachine
  File "/media/test/V2/lab/hack/ML-From-Scratch/supervised_learning/support_vector_machine.py", line 20, in <module>
    cvxopt.solvers.options['show_progress'] = False
AttributeError: 'module' object has no attribute 'solvers'`

k-means: TypeError: make_blobs() got an unexpected keyword argument 'noise'

Reproduction

python unsupervised_learning/k_means.py 

Diagnosis

This line caused the error:

X, y = datasets.make_blobs(noise=0.1)

Checked all scikit documentation for make_blobs:

None of them has noise parameter.

Perhaps what's needed is cluster_std?

scipy not in requirements.txt

When running the demo.py on my MacBook it said it missed the package.
It missed the scipy package. Could this be reflected back to the requirements.txt?

calculate_correlation_matrix

I use the calculate_correlation_matrix, and the result is greater than 1. is there any wrong?

it is convariance_matrix = (1 / (n_sample - 1)) * (X - X.mean(0)).T.dot(Y - Y.mean(0))?
is there some meaningful thing when the relation is greater than 1?

every function called has been tested. I think all are right.
x = np.array(np.random.random((10, 4))) print(calculate_variance(x)) print(calculate_std_dev(x)) print(calculate_convariance_matrix(x)) print(calculate_correlation_matrix(x))

the result is

[ 0.06257289 0.0854199 0.08613444 0.04435951]

[ 0.25014574 0.29226683 0.2934867 0.21061698]

[[ 0.06952543 -0.00037733 0.00416579 0.01641681]
[-0.00037733 0.094911 -0.02781782 0.0075379 ]
[ 0.00416579 -0.02781782 0.09570494 0.02909376]
[ 0.01641681 0.0075379 0.02909376 0.04928835]]

[[ 1.11111111 -0.00516115 0.05674344 0.31160352]
[-0.00516115 1.11111111 -0.32430615 0.1224553 ]
[ 0.05674344 -0.32430615 1.11111111 0.47067173]
[ 0.31160352 0.1224553 0.47067173 1.11111111]]

MatplotlibWrapper is an undefined name

MatplotlibWrapper is an undefined name in gaussian_mixture_model.py and k_means.py. Undefined names can raise NameError at runtime.

flake8 testing of https://github.com/eriklindernoren/ML-From-Scratch on Python 2.7.13

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./mlfromscratch/unsupervised_learning/gaussian_mixture_model.py:137:9: F821 undefined name 'MatplotlibWrapper'
    p = MatplotlibWrapper()
        ^

The same issue is also present in k_means.py but the * import masks it from flake8.

Runtime error during backward_pass() of PoolingLayer

I greatly appreciate your work and clearly written code which gives incredible insights into the back propagation technique. I've encountered a bit of a bug which is pretty solvable, but I don't want to make a pull request as I'm not sure of default values here.

It's at layers.py:400 (at the end of the line, last param):

accum_grad = column_to_image(accum_grad_col, (batch_size * channels, 1, height, width), self.pool_shape, self.stride, 0)

The last param is supposed to be in the string-style enum format of padding type. It's passing a literal 0 when it should be passing self.padding. PoolingLayer should also have a valid default value for self.padding which is also 0 (which of course causes this same error). In the case of 0 being an acceptable default, that value should be acceptable by the receiving function determine_padding, which is where the error is raised:
pad_h, pad_w = determine_padding(filter_shape, output_shape)

Again, thank you for this repository. Amazing work.

Python code standard

It would be nice if project would follow common python coding standards

$ pep8 . | wc -l
1080
$ pep257 . 2>&1 | wc -l
264

Genetic algorithm mutation rate

Issue with Genetic algorithm commit at Unsupervised learning.

The approach taken towards the initiation of mutation is a bit unrealistic. Given the fact that the mutation rate provided by the user isn't treated as a rate in it's original sense but rather it's being compared directly with the Numpy's random value, which makes it useless even if a high mutation rate was set.

ipynb

i think ipynb is better than py.

The gradient in gradient descent is not correct.

Since the gradient was built from MSE, it should be divided by the number of training examples. However, this number is omitted in the code. This makes the learning rate dependent on the number of training examples, because the more training examples you have, the bigger will be the gradient. The learning rate should not be dependent on the number of training examples.

grad_w = -(y - y_pred).dot(X) + self.regularization.grad(self.w)

Missing random feature selection in Random Forest construction.

As far I am concerned when constructing each tree in the random forest it is necessary to choose a random subset of features at "each" node of the tree, so a DecisionTree class can't be reused.

  1. Sample a random subset of the training data. (bagging)
  2. At each node of the tree sample a random subset of the original features and select the best.

What I observed in this implementation is that you are reusing the DecisionTree class and only randomly sampling the features once throughout all the tree.

  1. Sample a random subset of the training data. (bagging)
  2. Sample a random subset of the features of the sampled data.
  3. Feed the data into a DecisionTree.

I would like to know whether this is a legit implementation and where could I find more information about this implementation option.

By the way, your work is awesome and is helping students like me understand deeply machine learning algorithms.

Deep Learning Applications Classes

Great work here!
However, please could you kindly make available how your deep learning examples can be applied for use? ie

__init__.py activation_functions.py layers.py loss_functions.py neural_network.py optimizers.py

ImportError: when trying example

Terminal Session:

$ python mlfromscratch/examples/polynomial_regression.py
Traceback (most recent call last):
  File "mlfromscratch/examples/polynomial_regression.py", line 6, in <module>
    from mlfromscratch.supervised_learning import PolynomialRidgeRegression
  File "C:\users\aashutosh rathi\appdata\local\programs\python\python36\lib\site-packages\mlfromscratch-0.0.4-py3.6.egg\mlfromscratch\supervised_learning\__init__.py", line 14, in <module>
  File "C:\users\aashutosh rathi\appdata\local\programs\python\python36\lib\site-packages\mlfromscratch-0.0.4-py3.6.egg\mlfromscratch\supervised_learning\support_vector_machine.py", line 4, in <module>

  File "C:\users\aashutosh rathi\appdata\local\programs\python\python36\lib\site-packages\cvxopt-1.2.0-py3.6-win-amd64.egg\cvxopt\__init__.py", line 50, in <module>
    import cvxopt.base
ImportError: DLL load failed: The specified module could not be found.

Just a typo on a variable definition.

On the support vector machine, there is a typo on the definition of "self.intecept = None", later on it is called again as "self.intercept", as it supposedly should be defined.

An error raised when run dcgan.py.

I run python mlfromscratch/unsupervised_learning/dcgan.py,

The output is like that:

33 [D loss: 0.029268, acc: 100.00%] [G loss: 5.641379, acc: 0.00%]
34 [D loss: 0.024022, acc: 100.00%] [G loss: 5.165160, acc: 0.00%]
35 [D loss: 0.043149, acc: 96.88%] [G loss: 5.387241, acc: 0.00%]
36 [D loss: 0.017758, acc: 100.00%] [G loss: 5.255211, acc: 0.00%]
python2.7/lib/python2.7/site-packages/mlfromscratch-0.0.4-py2.7.egg/mlfromscratch/utils/layers.py:486: RuntimeWarning: invalid value encountered in multiply
python2.7/lib/python2.7/site-packages/mlfromscratch-0.0.4-py2.7.egg/mlfromscratch/utils/activation_functions.py:54: RuntimeWarning: invalid value encountered in greater_equal
python2.7/lib/python2.7/site-packages/mlfromscratch-0.0.4-py2.7.egg/mlfromscratch/utils/activation_functions.py:57: RuntimeWarning: invalid value encountered in greater_equal
37 [D loss: 0.020248, acc: 100.00%] [G loss: nan, acc: 100.00%]
38 [D loss: nan, acc: 50.00%] [G loss: nan, acc: 100.00%]
39 [D loss: nan, acc: 50.00%] [G loss: nan, acc: 100.00%]
40 [D loss: nan, acc: 50.00%] [G loss: nan, acc: 100.00%]
...

Thank you.

l1 regularization

Shouldn't class l1_regularization() be defined as self.alpha * np.linalg.norm(w, 1) instead of self.alpha * np.linalg.norm(w)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.