Some recommendations for budding machine learning engineers:

Published Mar 21 2019 01:33 PM 175 Views
Microsoft
First published on MSDN on Sep 19, 2018


Some Top Tips by Microsoft Software Engineer @DynamicWebPaige for getting started with DeepLearning

1) Make sure your sample dataset is representative of your entire population - and remember that more data is usually - but not necessarily! - better. Also consider using image preprocessing tools, like Augmentor. https://augmentor.readthedocs.io/en/master/code.html

2) Use small, random batches to train rather than the entire dataset. Reducing your batch size increases training time; but it also decreases the likelihood that your optimizer will settle into a local minimum instead of finding the global minimum (or something closer to it).

3) Make sure the data that you're using is standardized (mean and standard deviation for the training data should match that of the test data).  If you're using @TensorFlow , standardization can be accomplished with something like tf.nn.moments and tf.nn.batch_normalization. see https://www.tensorflow.org/api_docs/python/tf/nn

4) More layers isn't always better! And adding too many of 'em at the beginning often leads to overfitting.  Start with a few layers; if you aren't happy with accuracy, you can always add more. Another perk? The fewer layers you start out with, the faster the execution.

5) WEIGHT INITIALIZATION  Your weight initialization randomization function needs to be carefully chosen and specified; otherwise, there is a high risk that your training progress will be slow to the point of impractical. An option, in @TensorFlow : https://www.tensorflow.org/api_docs/python/tf/contrib/layers/xavier_initializer

6) Another attempt to combat overfitting: make sure to add dropout layers.  Dropout layers set a certain percentage of inputs to zero before passing the signals as output, which reduces codependency of the inputs. In @TensorFlow , you can use something like tf.nn.dropout. see https://www.tensorflow.org/api_docs/python/tf/nn

7) Monitor your gradients and your weights. Check them often. NNs frequently fail because weights get very, very big (exploding gradients) or very, very small / nonexistent (vanishing gradients). To resolve, adjust the number of layers in your model + activation functions see https://www.tensorflow.org/guide/summaries_and_tensorboard

8) Experiment with optimization algorithms! The most common aren't necessarily the best for your particular task; and researchers haven't reached consensus, either. A few of the most common: GradientDescentOptimizer, AdamOptimizer, AdagradOptimizer. https://www.tensorflow.org/api_guides/python/train

9) In addition to experimenting with optimizers, experiment with their learning rates (how the optimizer updates weights with each training step). Most of the time, learning rates vary from 0.0001 to 0.5 - and most examples you see in tutorials start at the higher end

10) Follow people who know what they're doing ( @DynamicWebPaige @JeffDean @fchollet @goodfellow_ian @drfeifei @karpathy etc); read books, blogposts, papers; attempt to reimplement what you see in literature; ask lots of questions. This stuff changes, every day.

Finally It's okay to feel overwhelmed.

%3CLINGO-SUB%20id%3D%22lingo-sub-381356%22%20slang%3D%22en-US%22%3ESome%20recommendations%20for%20budding%20machine%20learning%20engineers%3A%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-381356%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Sep%2019%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ESome%20Top%20Tips%20by%20Microsoft%20Software%20Engineer%20%3CSTRONG%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F96567i9BDDF495F6A03B22%22%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FDynamicWebPaige%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40DynamicWebPaige%20%3C%2FA%3E%20%3C%2FSTRONG%3E%20for%20getting%20started%20with%20DeepLearning%3C%2FP%3E%0A%20%20%3CP%3E1)%20Make%20sure%20your%20sample%20dataset%20is%20representative%20of%20your%20entire%20population%20-%20and%20remember%20that%20more%20data%20is%20usually%20-%20but%20not%20necessarily!%20-%20better.%20Also%20consider%20using%20image%20preprocessing%20tools%2C%20like%20Augmentor.%20%3CA%20href%3D%22https%3A%2F%2Faugmentor.readthedocs.io%2Fen%2Fmaster%2Fcode.html%22%20title%3D%22https%3A%2F%2Faugmentor.readthedocs.io%2Fen%2Fmaster%2Fcode.html%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Faugmentor.readthedocs.io%2Fen%2Fmaster%2Fcode.html%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E2)%20Use%20small%2C%20random%20batches%20to%20train%20rather%20than%20the%20entire%20dataset.%20Reducing%20your%20batch%20size%20increases%20training%20time%3B%20but%20it%20also%20decreases%20the%20likelihood%20that%20your%20optimizer%20will%20settle%20into%20a%20local%20minimum%20instead%20of%20finding%20the%20global%20minimum%20(or%20something%20closer%20to%20it).%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E3)%20Make%20sure%20the%20data%20that%20you're%20using%20is%20standardized%20(mean%20and%20standard%20deviation%20for%20the%20training%20data%20should%20match%20that%20of%20the%20test%20data).%26nbsp%3B%20If%20you're%20using%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FTensorFlow%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40TensorFlow%20%3C%2FA%3E%20%2C%20standardization%20can%20be%20accomplished%20with%20something%20like%20tf.nn.moments%20and%20tf.nn.batch_normalization.%20see%20%3CA%20href%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fnn%22%20title%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fnn%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fnn%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E4)%20More%20layers%20isn't%20always%20better!%20And%20adding%20too%20many%20of%20'em%20at%20the%20beginning%20often%20leads%20to%20overfitting.%26nbsp%3B%20Start%20with%20a%20few%20layers%3B%20if%20you%20aren't%20happy%20with%20accuracy%2C%20you%20can%20always%20add%20more.%20Another%20perk%3F%20The%20fewer%20layers%20you%20start%20out%20with%2C%20the%20faster%20the%20execution.%3C%2FP%3E%0A%20%20%3CP%3E5)%20WEIGHT%20INITIALIZATION%26nbsp%3B%20Your%20weight%20initialization%20randomization%20function%20needs%20to%20be%20carefully%20chosen%20and%20specified%3B%20otherwise%2C%20there%20is%20a%20high%20risk%20that%20your%20training%20progress%20will%20be%20slow%20to%20the%20point%20of%20impractical.%20An%20option%2C%20in%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FTensorFlow%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40TensorFlow%20%3C%2FA%3E%20%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fcontrib%2Flayers%2Fxavier_initializer%22%20title%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fcontrib%2Flayers%2Fxavier_initializer%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fcontrib%2Flayers%2Fxavier_initializer%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E6)%20Another%20attempt%20to%20combat%20overfitting%3A%20make%20sure%20to%20add%20dropout%20layers.%26nbsp%3B%20Dropout%20layers%20set%20a%20certain%20percentage%20of%20inputs%20to%20zero%20before%20passing%20the%20signals%20as%20output%2C%20which%20reduces%20codependency%20of%20the%20inputs.%20In%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FTensorFlow%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40TensorFlow%20%3C%2FA%3E%20%2C%20you%20can%20use%20something%20like%20tf.nn.dropout.%20see%20%3CA%20href%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fnn%22%20title%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fnn%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fwww.tensorflow.org%2Fapi_docs%2Fpython%2Ftf%2Fnn%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E7)%20Monitor%20your%20gradients%20and%20your%20weights.%20Check%20them%20often.%20NNs%20frequently%20fail%20because%20weights%20get%20very%2C%20very%20big%20(exploding%20gradients)%20or%20very%2C%20very%20small%20%2F%20nonexistent%20(vanishing%20gradients).%20To%20resolve%2C%20adjust%20the%20number%20of%20layers%20in%20your%20model%20%2B%20activation%20functions%20see%20%3CA%20href%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fguide%2Fsummaries_and_tensorboard%22%20title%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fguide%2Fsummaries_and_tensorboard%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fwww.tensorflow.org%2Fguide%2Fsummaries_and_tensorboard%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E8)%3C%2Fimg%3E%20Experiment%20with%20optimization%20algorithms!%20The%20most%20common%20aren't%20necessarily%20the%20best%20for%20your%20particular%20task%3B%20and%20researchers%20haven't%20reached%20consensus%2C%20either.%20A%20few%20of%20the%20most%20common%3A%20GradientDescentOptimizer%2C%20AdamOptimizer%2C%20AdagradOptimizer.%20%3CA%20href%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_guides%2Fpython%2Ftrain%22%20title%3D%22https%3A%2F%2Fwww.tensorflow.org%2Fapi_guides%2Fpython%2Ftrain%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fwww.tensorflow.org%2Fapi_guides%2Fpython%2Ftrain%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E9)%20In%20addition%20to%20experimenting%20with%20optimizers%2C%20experiment%20with%20their%20learning%20rates%20(how%20the%20optimizer%20updates%20weights%20with%20each%20training%20step).%20Most%20of%20the%20time%2C%20learning%20rates%20vary%20from%200.0001%20to%200.5%20-%20and%20most%20examples%20you%20see%20in%20tutorials%20start%20at%20the%20higher%20end%3C%2FP%3E%0A%20%20%3CP%3E10)%20Follow%20people%20who%20know%20what%20they're%20doing%20(%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FDynamicWebPaige%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40DynamicWebPaige%20%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2FJeffDean%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40JeffDean%20%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Ffchollet%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40fchollet%20%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fgoodfellow_ian%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40goodfellow_ian%20%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fdrfeifei%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40drfeifei%20%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Ftwitter.com%2Fkarpathy%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20%40karpathy%20%3C%2FA%3E%20etc)%3B%20read%20books%2C%20blogposts%2C%20papers%3B%20attempt%20to%20reimplement%20what%20you%20see%20in%20literature%3B%20ask%20lots%20of%20questions.%20This%20stuff%20changes%2C%20every%20day.%3C%2FP%3E%0A%20%20%3CP%3EFinally%20It's%20okay%20to%20feel%20overwhelmed.%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-381356%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Sep%2019%2C%202018%20Some%20Top%20Tips%20by%20Microsoft%20Software%20Engineer%20%40DynamicWebPaige%20for%20getting%20started%20with%20DeepLearning1)%20Make%20sure%20your%20sample%20dataset%20is%20representative%20of%20your%20entire%20population%20-%20and%20remember%20that%20more%20data%20is%20usually%20-%20but%20not%20necessarily!%20-%20better.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-381356%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eacademic%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Edeep%20learning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Efaculty%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Elearning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Estudent%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Estudents%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Mar 21 2019 01:33 PM
Updated by: