id
int64
0
25.6k
text
stringlengths
0
4.59k
11,400
what is deep learningfinding these transformationsthey're merely searching through predefined set of operationscalled hypothesis space so that' what machine learning istechnicallysearching for useful representations of some input datawithin predefined space of possibilitiesusing guidance from feedback signal this simpl...
11,401
artificial intelligencemachine learningand deep learning what do the representations learned by deep-learning algorithm look likelet' examine how network several layers deep (see figure transforms an image of digit in order to recognize what digit it is layer layer layer layer original input final output figure deep ne...
11,402
what is deep learningmapping via deep sequence of simple data transformations (layersand that these data transformations are learned by exposure to examples now let' look at how this learning happensconcretely the specification of what layer does to its input data is stored in the layer' weightswhich in essence are bun...
11,403
the fundamental trick in deep learning is to use this score as feedback signal to adjust the value of the weights littlein direction that will lower the loss score for the current example (see figure this adjustment is the job of the optimizerwhich implements what' called the backpropagation algorithmthe central algori...
11,404
what is deep learningimproved text-to-speech conversion digital assistants such as google now and amazon alexa near-human-level autonomous driving improved ad targetingas used by googlebaiduand bing improved search results on the web ability to answer natural-language questions superhuman go playing we're still explori...
11,405
we may be currently witnessing the third cycle of ai hype and disappointment-and we're still in the phase of intense optimism it' best to moderate our expectations for the short term and make sure people less familiar with the technical side of the field have clear idea of what deep learning can and can' deliver the pr...
11,406
what is deep learningbefore deep learninga brief history of machine learning deep learning has reached level of public attention and industry investment never before seen in the history of aibut it isn' the first successful form of machine learning it' safe to say that most of the machine-learning algorithms used in th...
11,407
when multiple people independently rediscovered the backpropagation algorithm- way to train chains of parametric operations using gradient-descent optimization (later in the bookwe'll precisely define these concepts)--and started applying it to neural networks the first successful practical application of neural nets c...
11,408
what is deep learninghyperplanes in the new representation spaceyou don' have to explicitly compute the coordinates of your points in the new spaceyou just need to compute the distance between pairs of points in that spacewhich can be done efficiently using kernel function kernel function is computationally tractable o...
11,409
uses gradient boostinga way to improve any machine-learning model by iteratively training new models that specialize in addressing the weak points of the previous models applied to decision treesthe use of the gradient boosting technique results in models that strictly outperform random forests most of the timewhile ha...
11,410
what is deep learningproblem-solving much easierbecause it completely automates what used to be the most crucial step in machine-learning workflowfeature engineering previous machine-learning techniques--shallow learning--only involved transforming the input data into one or two successive representation spacesusually ...
11,411
in and kaggle was dominated by two approachesgradient boosting machines and deep learning specificallygradient boosting is used for problems where structured data is availablewhereas deep learning is used for perceptual problems such as image classification practitioners of the former almost always use the excellent xg...
11,412
what is deep learningwhy deep learningwhy nowthe two key ideas of deep learning for computer vision--convolutional neural networks and backpropagation--were already well understood in the long shortterm memory (lstmalgorithmwhich is fundamental to deep learning for timeserieswas developed in and has barely changed sinc...
11,413
what happened is that the gaming market subsidized supercomputing for the next generation of artificial intelligence applications sometimesbig things begin as games todaythe nvidia titan xa gaming gpu that cost $ , at the end of can deliver peak of tflops in single precision trillion float operations per second that' a...
11,414
what is deep learningusing only one or two layers of representationsthusthey weren' able to shine against more-refined shallow methods such as svms and random forests the key issue was that of gradient propagation through deep stacks of layers the feedback signal used to train neural networks would fade away as the num...
11,415
as result of this wave of investmentthe number of people working on deep learning went in just five years from few hundred to tens of thousandsand research progress has reached frenetic pace there are currently no signs that this trend will slow any time soon the democratization of deep learning one of the key factors ...
11,416
what is deep learningcomplex and powerful models this also makes deep learning applicable to fairly small datasets deep learning has only been in the spotlight for few yearsand we haven' yet established the full scope of what it can do with every passing monthwe learn about new use cases and engineering improvements th...
11,417
mathematical building blocks of neural networks this covers first example of neural network tensors and tensor operations how neural networks learn via backpropagation and gradient descent understanding deep learning requires familiarity with many simple mathematical conceptstensorstensor operationsdifferentiationgradi...
11,418
before we beginthe mathematical building blocks of neural networks that' been introducedpoint by point keep in mind that these concepts will be essential for you to understand the practical examples that will come in the following after reading this you'll have an intuitive understanding of how neural networks workand ...
11,419
first look at neural network let' look at concrete example of neural network that uses the python library keras to learn to classify handwritten digits unless you already have experience with keras or similar librariesyou won' understand everything about this first example right away you probably haven' even installed ...
11,420
before we beginthe mathematical building blocks of neural networks the images are encoded as numpy arraysand the labels are an array of digitsranging from to the images and labels have one-to-one correspondence let' look at the training datatrain_images shape ( len(train_labels train_labels array([ ]dtype=uint and here...
11,421
to make the network ready for trainingwe need to pick three more thingsas part of the compilation stepa loss function--how the network will be able to measure its performance on the training dataand thus how it will be able to steer itself in the right direction an optimizer--the mechanism through which the network wil...
11,422
before we beginthe mathematical building blocks of neural networks two quantities are displayed during trainingthe loss of the network over the training dataand the accuracy of the network over the training data we quickly reach an accuracy of ( %on the training data now let' check that the model performs well on the t...
11,423
data representations for neural networks in the previous examplewe started from data stored in multidimensional numpy arraysalso called tensors in generalall current machine-learning systems use tensors as their basic data structure tensors are fundamental to the field--so fundamental that google' tensorflow was named ...
11,424
before we beginthe mathematical building blocks of neural networks np array([[ ][ ][ ]] ndim the entries from the first axis are called the rowsand the entries from the second axis are called the columns in the previous example[ is the first row of xand [ is the first column tensors and higher-dimensional tensors if yo...
11,425
to make this more concretelet' look back at the data we processed in the mnist example firstwe load the mnist datasetfrom keras datasets import mnist (train_imagestrain_labels)(test_imagestest_labelsmnist load_data(nextwe display the number of axes of the tensor train_images the ndim attributeprint(train_images ndim he...
11,426
before we beginthe mathematical building blocks of neural networks manipulating tensors in numpy in the previous examplewe selected specific digit alongside the first axis using the syntax train_images[iselecting specific elements in tensor is called tensor slicing let' look at the tensor-slicing operations you can do ...
11,427
when considering such batch tensorthe first axis (axis is called the batch axis or batch dimension this is term you'll frequently encounter when using keras and other deep-learning libraries real-world examples of data tensors let' make data tensors more concrete with few examples similar to what you'll encounter later...
11,428
before we beginthe mathematical building blocks of neural networks the time axis is always the second axis (axis of index )by convention let' look at few examplesa dataset of stock prices every minutewe store the current price of the stockthe highest price in the past minuteand the lowest price in the past minute thus ...
11,429
the theano conventionthe previous examples would become ( and ( the keras framework provides support for both formats video data video data is one of the few types of real-world data for which you'll need tensors video can be understood as sequence of frameseach frame being color image because each frame can be stored ...
11,430
before we beginthe mathematical building blocks of neural networks the gears of neural networkstensor operations much as any computer program can be ultimately reduced to small set of binary operations on binary inputs (andornorand so on)all transformations learned by deep neural networks can be reduced to handful of t...
11,431
you do the same for additionx and are numpy tensors def naive_add(xy)assert len( shape= assert shape = shape copy(for in range( shape[ ])for in range( shape[ ]) [ij+ [ijreturn avoid overwriting the input tensor on the same principleyou can do element-wise multiplicationsubtractionand so on in practicewhen dealing with ...
11,432
before we beginthe mathematical building blocks of neural networks repeated times alongside new axis is helpful mental model here' what naive implementation would look likedef naive_add_matrix_and_vector(xy)assert len( shape= assert len( shape= assert shape[ = shape[ copy(for in range( shape[ ])for in range( shape[ ]) ...
11,433
for in range( shape[ ]) + [iy[ireturn you'll have noticed that the dot product between two vectors is scalar and that only vectors with the same number of elements are compatible for dot product you can also take the dot product between matrix and vector ywhich returns vector where the coefficients are the dot products...
11,434
before we beginthe mathematical building blocks of neural networks to understand dot-product shape compatibilityit helps to visualize the input and output tensors by aligning them as shown in figure shape(bcx = column of shape(acx shape(abz ij row of figure mat rix dot-product box diagram xyand are pictured as rectangl...
11,435
the gears of neural networkstensor operations reshape(( ) array([ ] ] ] ] ] ]] reshape(( ) array([ ] ]] special case of reshaping that' commonly encountered is transposition transposing matrix means exchanging its rows and its columnsso that [ :becomes [: ] np zeros(( ) np transpose(xprint( shape( creates an all-zeros ...
11,436
before we beginthe mathematical building blocks of neural networks let' consider new pointb [ ]which we'll add to the previous one this is done geometrically by chaining together the vector arrowswith the resulting location being the vector representing the sum of the previous two vectors (see figure + figure geometric...
11,437
uncrumpling paper balls is what machine learning is aboutfinding neat representations for complexhighly folded data manifolds at this pointyou should have pretty good intuition as to why deep learning excels at thisit takes the approach of incrementally decomposing complicated geometric transformation into long chain o...
11,438
before we beginthe mathematical building blocks of neural networks the engine of neural networksgradient-based optimization as you saw in the previous sectioneach neural layer from our first network example transforms its input data as followsoutput relu(dot(winputbin this expressionw and are tensors that are attribute...
11,439
would contribute to minimizing the loss this would have to be repeated for all coefficients in the network but such an approach would be horribly inefficientbecause you' need to compute two forward passes (which are expensivefor every individual coefficient (of which there are manyusually thousands and sometimes up to ...
11,440
before we beginthe mathematical building blocks of neural networks points for instancethe derivative of cos(xis -sin( )the derivative of (xa is '(xaand so on if you're trying to update by factor epsilon_x in order to minimize ( )and you know the derivative of fthen your job is donethe derivative completely describes ho...
11,441
applied to neural networkthat means finding analytically the combination of weight values that yields the smallest possible loss function this can be done by solving the equation gradient( )( for this is polynomial equation of variableswhere is the number of coefficients in the network although it would be possible to ...
11,442
before we beginthe mathematical building blocks of neural networks as you can seeintuitively it' important to pick reasonable value for the step factor if it' too smallthe descent down the curve will take many iterationsand it could get stuck in local minimum if step is too largeyour updates may end up taking you to co...
11,443
loss value local minimum global minimum parameter value figure local minimum and global minimum as you can seearound certain parameter valuethere is local minimumaround that pointmoving left would result in the loss increasingbut so would moving right if the parameter under consideration were being optimized via sgd wi...
11,444
before we beginthe mathematical building blocks of neural networks called backpropagation (also sometimes called reverse-mode differentiationbackpropagation starts with the final loss value and works backward from the top layers to the bottom layersapplying the chain rule to compute the contribution that each parameter...
11,445
looking back at our first example you've reached the end of this and you should now have general understanding of what' going on behind the scenes in neural network let' go back to the first example and review each piece of it in the light of what you've learned in the previous three sections this was the input data(tr...
11,446
before we beginthe mathematical building blocks of neural networks accordingly after these epochsthe network will have performed , gradient updates ( per epoch)and the loss of the network will be sufficiently low that the network will be capable of classifying handwritten digits with high accuracy at this pointyou alre...
11,447
summary learning means finding combination of model parameters that minimizes loss function for given set of training data samples and their corresponding targets learning happens by drawing random batches of data samples and their targetsand computing the gradient of the network parameters with respect to the loss on ...
11,448
with neural networks this covers core components of neural networks an introduction to keras setting up deep-learning workstation using neural networks to solve basic classification and regression problems this is designed to get you started with using neural networks to solve real problems you'll consolidate the knowl...
11,449
tensorflowkerasand gpu support we'll dive into three introductory examples of how to use neural networks to address real problemsclassifying movie reviews as positive or negative (binary classificationclassifying news wires by topic (multiclass classificationestimating the price of housegiven real-estate data (regressi...
11,450
getting started with neural networks anatomy of neural network as you saw in the previous training neural network revolves around the following objectslayerswhich are combined into network (or modelthe input data and corresponding targets the loss functionwhich defines the feedback signal used for learning the optimize...
11,451
anatomy of neural network you can think of layers as the lego bricks of deep learninga metaphor that is made explicit by frameworks like keras building deep-learning models in keras is done by clipping together compatible layers to form useful data-transformation pipelines the notion of layer compatibility here refers ...
11,452
getting started with neural networks picking the right network architecture is more an art than scienceand although there are some best practices and principles you can rely ononly practice can help you become proper neural-network architect the next few will both teach you explicit principles for building neural netwo...
11,453
introduction to keras throughout this bookthe code examples use keras (deep-learning framework for python that provides convenient way to define and train almost any kind of deep-learning model keras was initially developed for researcherswith the aim of enabling fast experimentation keras has the following key feature...
11,454
getting started with neural networks kerastensorflowtheanoand cntk keras is model-level libraryproviding high-level building blocks for developing deep-learning models it doesn' handle low-level operations such as tensor manipulation and differentiation insteadit relies on specializedwell-optimized tensor library to do...
11,455
configure the learning process by choosing loss functionan optimizerand some metrics to monitor iterate on your training data by calling the fit(method of your model there are two ways to define modelusing the sequential class (only for linear stacks of layerswhich is the most common network architecture by faror the f...
11,456
getting started with neural networks over the next few you'll build solid intuition about what type of network architectures work for different kinds of problemshow to pick the right learning configurationand how to tweak model until it gives the results you want to see we'll look at three basic examples in sections an...
11,457
setting up deep-learning workstation before you can get started developing deep-learning applicationsyou need to set up your workstation it' highly recommendedalthough not strictly necessarythat you run deep-learning code on modern nvidia gpu some applications--in particularimage processing with convolutional networks ...
11,458
getting started with neural networks getting keras runningtwo options to get started in practicewe recommend one of the following two optionsuse the official ec deep learning ami (you don' already have gpu on your local machine appendix provides step-by-step guide install everything from scratch on local unix workstati...
11,459
from this section onwardwe'll assume that you have access to machine with keras and its dependencies installed--preferably with gpu support make sure you finish this step before you proceed go through the step-by-step guides in the appendixesand look online if you need further help there is no shortage of tutorials on ...
11,460
getting started with neural networks classifying movie reviewsa binary classification example two-class classificationor binary classificationmay be the most widely applied kind of machine-learning problem in this exampleyou'll learn to classify movie reviews as positive or negativebased on the text content of the revi...
11,461
classifying movie reviewsa binary classification example because you're restricting yourself to the top , most frequent wordsno word index will exceed , max([max(sequencefor sequence in train_data] for kickshere' how you can quickly decode one of these reviews back to english wordsword_index is dictionary mapping words...
11,462
getting started with neural networks here' what the samples look like nowx_train[ array( ]you should also vectorize your labelswhich is straightforwardy_train np asarray(train_labelsastype('float 'y_test np asarray(test_labelsastype('float 'now the data is ready to be fed into neural network building your network the i...
11,463
indicating how likely the sample is to have the target " "how likely the review is to be positivea relu (rectified linear unitis function meant to zero out negative values (see figure )whereas sigmoid "squashesarbitrary values into the [ interval (see figure )outputting something that can be interpreted as probability ...
11,464
getting started with neural networks output (probabilitydense (units= dense (units= dense (units= sequential input (vectorized textfigure the hree-layer net work figure shows what the network looks like and here' the keras implementationsimilar to the mnist example you saw previously listing the model definit ion from ...
11,465
binary_crossentropy loss it isn' the only viable choiceyou could usefor instancemean_squared_error but crossentropy is usually the best choice when you're dealing with models that output probabilities crossentropy is quantity from the field of information theory that measures the distance between probability distributi...
11,466
getting started with neural networks y_val y_train[: partial_y_train y_train[ :you'll now train the model for epochs ( iterations over all samples in the x_train and y_train tensors)in mini-batches of samples at the same timeyou'll monitor loss and accuracy on the , samples that you set apart you do so by passing the v...
11,467
figure training and validat ion loss listing plot ing he raining and validat ion accuracy plt clf(clears the figure acc_values history_dict['acc'val_acc_values history_dict['val_acc'plt plot(epochsacc'bo'label='training acc'plt plot(epochsval_acc' 'label='validation acc'plt title('training and validation accuracy'plt x...
11,468
getting started with neural networks as you can seethe training loss decreases with every epochand the training accuracy increases with every epoch that' what you would expect when running gradientdescent optimization--the quantity you're trying to minimize should be less with every iteration but that isn' the case for...
11,469
as you can seethe network is confident for some samples ( or moreor or lessbut less confident for others ( further experiments the following experiments will help convince you that the architecture choices you've made are all fairly reasonablealthough there' still room for improvementyou used two hidden layers try usin...
11,470
classifying newswiresa multiclass classification example getting started with neural networks in the previous sectionyou saw how to classify vector inputs into two mutually exclusive classes using densely connected neural network but what happens when you have more than two classesin this sectionyou'll build network to...
11,471
the label associated with an example is an integer between and -- topic indextrain_labels[ preparing the data you can vectorize the data with the exact same code as in the previous example listing encoding he dat import numpy as np def vectorize_sequences(sequencesdimension= )results np zeros((len(sequences)dimension)f...
11,472
getting started with neural networks relevant to the classification problemthis information can never be recovered by later layerseach layer can potentially become an information bottleneck in the previous exampleyou used -dimensional intermediate layersbut -dimensional space may be too limited to learn to separate dif...
11,473
nowlet' train the network for epochs listing training he model history model fit(partial_x_trainpartial_y_trainepochs= batch_size= validation_data=(x_valy_val)and finallylet' display its loss and accuracy curves (see figures and listing plot ing he raining and validat ion loss import matplotlib pyplot as plt loss histo...
11,474
getting started with neural networks figure training and validation accuracy the network begins to overfit after nine epochs let' train new network from scratch for nine epochs and then evaluate it on the test set listing ret raining model from scrat ch model models sequential(model add(layers dense( activation='relu'i...
11,475
generating predictions on new data you can verify that the predict method of the model instance returns probability distribution over all topics let' generate topic predictions for all of the test data listing generat ing predict ions for new dat predictions model predict(x_testeach entry in predictions is vector of le...
11,476
listing getting started with neural networks model with an informat ion bot leneck model models sequential(model add(layers dense( activation='relu'input_shape=( ,))model add(layers dense( activation='relu')model add(layers dense( activation='softmax')model compile(optimizer='rmsprop'loss='categorical_crossentropy'metr...
11,477
predicting house pricesa regression example the two previous examples were considered classification problemswhere the goal was to predict single discrete label of an input data point another common type of machine-learning problem is regressionwhich consists of predicting continuous value instead of discrete labelfor ...
11,478
getting started with neural networks preparing the data it would be problematic to feed into neural network values that all take wildly different ranges the network might be able to automatically adapt to such heterogeneous databut it would definitely make learning more difficult widespread best practice to deal with s...
11,479
predicting house pricesa regression example note that you compile the network with the mse loss function--mean squared errorthe square of the difference between the predictions and the targets this is widely used loss function for regression problems you're also monitoring new metric during trainingmean absolute error ...
11,480
getting started with neural networks prepares the validation datadata from partition prepares the training datadata from all other partitions for in range( )print('processing fold #'ival_data train_data[ num_val_samples( num_val_samplesval_targets train_targets[ num_val_samples( num_val_samplespartial_train_data np con...
11,481
predicting house pricesa regression example partial_train_targets np concatenate[train_targets[: num_val_samples]train_targets[( num_val_samples:]]axis= builds the keras model (already compiledmodel build_model(history model fit(partial_train_datapartial_train_targetsvalidation_data=(val_dataval_targets)epochs=num_epoc...
11,482
getting started with neural networks the result is shown in figure listing plot ing validat ion scoresexcluding he first dat point def smooth_curve(pointsfactor= )smoothed_points [for point in pointsif smoothed_pointsprevious smoothed_points[- smoothed_points append(previous factor point ( factor)elsesmoothed_points ap...
11,483
here' the final resulttest_mae_score you're still off by about $ , wrapping up here' what you should take away from this exampleregression is done using different loss functions than what we used for classification mean squared error (mseis loss function commonly used for regression similarlyevaluation metrics to be us...
11,484
getting started with neural networks summary you're now able to handle the most common kinds of machine-learning tasks on vector databinary classificationmulticlass classificationand scalar regression the "wrapping upsections earlier in the summarize the important points you've learned regarding these types of tasks yo...
11,485
machine learning this covers forms of machine learning beyond classification and regression formal evaluation procedures for machinelearning models preparing data for deep learning feature engineering tackling overfitting the universal workflow for approaching machinelearning problems after the three practical examples...
11,486
fundamentals of machine learning four branches of machine learning in our previous examplesyou've become familiar with three specific types of machine-learning problemsbinary classificationmulticlass classificationand scalar regression all three are instances of supervised learningwhere the goal is to learn the relatio...
11,487
human-annotated labels--you can think of it as supervised learning without any humans in the loop there are still labels involved (because the learning has to be supervised by something)but they're generated from the input datatypically using heuristic algorithm for instanceautoencoders are well-known instance of self-...
11,488
fundamentals of machine learning (continuedprediction error or loss value-- measure of the distance between your model' prediction and the target classes-- set of possible labels to choose from in classification problem for examplewhen classifying cat and dog picturesdogand catare the two classes label-- specific insta...
11,489
evaluating machine-learning models in the three examples presented in we split the data into training seta validation setand test set the reason not to evaluate the models on the same data they were trained on quickly became evidentafter just few epochsall three models began to overfit that istheir performance on never...
11,490
fundamentals of machine learning if anything about the model has been tuned based on test set performancethen your measure of generalization will be flawed splitting your data into trainingvalidationand test sets may seem straightforwardbut there are few advanced ways to do it that can come in handy when little data is...
11,491
evaluating machine-learning models this is the simplest evaluation protocoland it suffers from one flawif little data is availablethen your validation and test sets may contain too few samples to be statistically representative of the data at hand this is easy to recognizeif different random shuffling rounds of the dat...
11,492
fundamentals of machine learning validation_score np average(validation_scoresmodel get_model(model train(datatest_score model evaluate(test_datatrains the final model on all nontest data available validation scoreaverage of the validation scores of the folds iterated -fold validation with shuffling this one is for sit...
11,493
data preprocessingfeature engineeringand feature learning in addition to model evaluationan important question we must tackle before we dive deeper into model development is the followinghow do you prepare the input data and targets before feeding them into neural networkmany data-preprocessing and feature-engineering ...
11,494
fundamentals of machine learning additionallythe following stricter normalization practice is common and can helpalthough it isn' always necessary (for exampleyou didn' do this in the digit-classification example)normalize each feature independently to have mean of normalize each feature independently to have standard ...
11,495
if you choose to use the raw pixels of the image as input datathen you have difficult machine-learning problem on your hands you'll need convolutional neural network to solve itand you'll have to expend quite bit of computational resources to train the network but if you already understand the problem at high level (yo...
11,496
fundamentals of machine learning overfitting and underfitting in all three examples in the previous -predicting movie reviewstopic classificationand house-price regression--the performance of the model on the held-out validation data always peaked after few epochs and then began to degradethe model quickly started to o...
11,497
we' need only binary parameters for each of the , digits but such model would be useless for classifying new digit samples always keep this in minddeeplearning models tend to be good at fitting to the training databut the real challenge is generalizationnot fitting on the other handif the network has limited memorizati...
11,498
fundamentals of machine learning figure effect of model capacit on validat ion losst rying smaller model as you can seethe smaller network starts overfitting later than the reference network (after six epochs rather than four)and its performance degrades more slowly once it starts overfitting nowfor kickslet' add to th...
11,499
overfitting and underfitting the bigger network starts overfitting almost immediatelyafter just one epochand it overfits much more severely its validation loss is also noisier meanwhilefigure shows the training losses for the two networks as you can seethe bigger network gets its training loss near zero very quickly th...