GithubHelp home page GithubHelp logo

bryantpq / ai_classifiers Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 76 KB

CSE 415 Project on Random Forests and Neural Networks Classifiers

License: MIT License

Python 47.56% Jupyter Notebook 52.44%

ai_classifiers's People

Contributors

bryantpq avatar wild-dogs avatar

Watchers

 avatar  avatar

ai_classifiers's Issues

Inefficient sampling in NN Train

Within


def train(self, X, y,
              learning_rate=1e-3, learning_rate_decay=0.95,
              reg=5e-6, num_iters=100,
              batch_size=200, verbose=False):
        """
        Trains the model with stochastic gradient descent
        """
        num_train = X.shape[0]
        iterations_per_epoch = max(num_train / batch_size, 1)


        for it in range(num_iters):
            X_batch = None
            y_batch = None

            r_indices = np.random.choice(num_train, batch_size)
  1. The typical flow is for each epoch (what you call a num_iters), you iterate through the entire dataset once (you typically shuffle the indices and iterate through that instead of doing a random choice each time).

Effectively, if you have a dataset of size N, and your num_iters is of size m, you train on N x m samples.

What you're doing is effectively training on m x batch_size if that makes sense.

  1. instead of calling random.choice you should generate an indexing array of length of dataset, then permute that array to pass through your dataset - it's more efficient and much less expensive. Also, you don't run into the issue of accidentally selecting the same index again and again as can happen above

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.