All Flashcards

1
Q

What is TensorFlow?

A

TensorFlow is an open-source, high-performance library for numerical computation, any numerical computation, not just for machine learning.

It is a scalable and multi-platform programming interface for implementing and running machine learning algorithms, including convenience wrappers for deep learning.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Tensor?

A

It is an N-dimensional array.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What tf.GradientTape is used for?

A

TensorFlow records all operations executed inside the context of tf.GradientTape onto a tape

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does TensorFlow represent numeric computations?

A

Using a Directed Acyclic Graph (or DAG)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which API is used to build performant, complex input pipelines from simple, re-usable pieces that will feed your model’s training or evaluation loops.

A

tf.data.Dataset

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is tf.data API ?

A
  • The tf.data API introduces the tf.data.Dataset abstraction that represents a sequence of elements, in which each element consists of one or more components. For example, in an image pipeline.
  • The dataset API will help you create input functions for your model that load data in progressively, throttling it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why are there two functions for mapping, map and flat_map?

A

One of them is to simple do a one-for-one transformation and the other one is one-to-many transformations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What prefetching allows you to do?

A

Prefetching allows for subsequent batches to be prepared as soon as their previous batches have been sent away for computation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to increase speed of processing in TensorFlow?

A

By combining prefetching and multi-threaded loading and preprocessing, you can achieve a very good performance by making sure that each of your GPUs or CPUs are constantly busy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How categorical columns are represented in TensorFlow?

A

Categorical columns are represented in TensorFlow as sparse tensors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What embedding vectors are used for?

A

As the number of categories of a feature grows large, it becomes infeasible to train a neural network using one-hot encodings. Use an embedding column to overcome this limitation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the purposes of embedding vectors?

A
  • finding nearest neighbors in the embedding space
  • as input into a machine learning model for a supervised task
  • for visualization of concepts and relations between categories (can use TensorBoard)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What Keras preprocessing API is for?

A
  • Combined with TensorFlow, the Keras preprocessing layers API allows TensorFlow developers to build Keras native input processing pipelines.
  • With Keras preprocessing layers, you can build and export models that are truly end-to-end.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

List available preprocessing layers in Keras.

A

The available preprocessing layers include
- text preprocessing,
- numerical features preprocessing,
- categorical features preprocessing
- image preprocessing
- image data augmentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Wich Keras preprocessing layers are used for categorical values?

A
  • Tf.keras.layers.CategoryEncoding
  • Tf.keras.layers.Hashing
  • Tf.keras.layers.StringLookup
  • Tf.keras.layers.IntegerLookup
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What Tf.keras.layers.IntegerLookup does?

A

It urns integer categorical values into an encoded representation that can be read by an Embedding layer or a Dense layer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What Tf.keras.layers.StringLookup does?

A

It turns string categorical values into an encoded representation that can be read by an Embedding layer or a Dense layer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What Tf.keras.layers.Hashing does?

A

It performs categorical feature hashing, also known as “the hashing trick.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What Tf.keras.layers.CategoryEncoding does?

A

It turns integer categorical features into one-hot, multi-hot, or count-dense representations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What preprocessing layers support multiple states that are computed based on the dataset at the given time?

A
  • TextVectorization (which holds a map between string tokens and integer indices)
  • StringLookup and IntegerLookup (which holds a mapping between input values and integer indices)
  • Normalization (which holds the mean and standard deviation of the features)
  • Discretization (which holds information about the value bucket boundaries)

Note
These layers are nontrainable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What does it mean that layers are nontrainable?

A

Their state is not set during training. It must be set before training, either by initializing them, from a precomputed constant, or by adapting them on data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

When should you avoid using the Keras function adapt()?

A

When working with lookup layers with very large vocabularies

23
Q

What are distinct ways to create a dataset?

A

A data source constructs a Dataset from data stored in memory or in one or more files and a data transformation constructs a dataset from one or more tf.data.Dataset objects.

24
Q

Which is true regarding feature columns?

A

Feature columns describe how the model should use raw input data from your features dictionary.

25
Q

What is the use of tf.keras.layers.TextVectorization?

A

It turns raw strings into an encoded representation that can be read by an Embedding layer or Dense layer.

26
Q

How do you escape from having just a linear model in NN?

A

By adding a nonlinear transformation layer, which is facilitated by a nonlinear activation function such as a sigmoid, tanH or ReLU.

27
Q

How to prevent the neural network from condensing back down into a shallow network?

A

By adding a nonlinear transformation layer, which is facilitated by a nonlinear activation function such as a sigmoid, tanH or ReLU.

28
Q

What is NN the vanishing gradient problem?

A

When there are more layers in the network, the value of the product of derivative decreases until at some point the partial derivative of the loss function approaches a value close to zero, and the partial derivative vanishes. As a result the models’ weights don’t update .

29
Q

What is the dvantage of using ReLU activation function?

A

Networks with ReLU hidden activations often have 10 times the speed of training than networks with sigmoid hidden activations.

30
Q

Describe ReLU layers dying problem.

A

Due to the negative domain’s function always being zero, we can end up with ReLU layers dying. Now, what I mean by that is, you’ll start getting inputs in the negative domain.

Then, the output of the activation will be zero, negative times zero, zero, which doesn’t help in the next layer getting the inputs back into the positive domain. It’s still going to be zero.

Some extensions to ReLU meant to relax the nonlinear output of the function and to allow small negative values:
Leaky ReLU, logistics sigmoid function .

31
Q

What is tf.Keras?

A

TF.Keras, again, that’s TensorFlow’s high level API for building and training deep learning models.

32
Q

List advantages of tf.Keras.

A
  • user friendly
  • modular and composable
  • easy to extend
33
Q

When Sequential models are not advisable?

A
  • if the model has multiple inputs or multiple outputs.
  • if any of the layers in the model have multiple inputs and multiple outputs that, that model needs to do layer sharing
  • if the model has a nonlinear topology such as a residual connection or if it multi-branches.
34
Q

What is Stochastic Gradient Descent?

A
  • An optimizer that’s generally used in machine learning.
  • SGD is an algorithm that descends the slope, hence the name, to reach the lowest point on that loss surface.
35
Q

What is the role of the optimizer in NN model?

A

Optimizers tie together that loss function and the model parameters by actually doing the updating of the model in response to the output of the loss function.

36
Q

What are the advantages of Adam optimizer?

A
  • computationally efficient
  • having little memory requirements
  • its invariability due to the diagonal rescaling of the gradients.
37
Q

When is it advisable to use the Adam optimizer?

A

Adam is well-suited for
- models that have large data sets
- if you have a lot of parameters that you’re adjusting
- problems with very noisy or sparse gradients and nonstationary objectives

38
Q

Why do you need to export the trained model to a TensorFlow SavedModel format?

A

Once we have a model in this format, we have many ways to serve the model, web application, code like JavaScript, from a mobile application, etc.

39
Q

What is SavedModel in TensorFlow?

A

SavedModel is a universal serialization format for TensorFlow models.

40
Q

What are the advantages of SavedModel in TensorFlow?

A
  • language neutral format to save your machine learning models that is both recoverable and hermetic.
  • It enables higher level systems and tools to produce, consume and transform your TensorFlow models.
  • Models saved in this format can be restored using the tf
41
Q

What Keras Sequential API does not allow?

A

to create models that
- share layers
- reuse layers
- have multiple inputs or outputs.

Use functional API instead.

42
Q

What are the strengths of Keras functional API?

A
  • It’s less verbose than using keras.Model subclasses
  • It validates your model while you’re defining it
  • Your functional model is plottable and respectable.
  • model can be serialized or cloned.
43
Q

What are the weaknesses of Keras functional API?

A
  • It does not support dynamic architectures
  • Sometimes, you just need to write everything from scratch. When writing advanced architectures, you may want to do things that are outside the scope of defining a DAG of layers
44
Q

Why recursive networks or Tree-RNNs cannot be implemented in the functional API?

A

The functional API treats models as DAGs, or directed acyclic graphs, of those layers. Since recursive networks or Tree-RNNs, do not follow this assumption.

45
Q

Describe the spectrum of model building in Keras.

A
  • The sequential model (consists of a simple list of layers but is limited to single-input, single-output stacks of layers
  • The functional API ( supports arbitrary model architectures. It is Keras industry strength modeling)
  • The subclassing (you implement everything from scratch on your own. You should use this if you have complex, out-of-the-box research use cases)
46
Q

How does Adam (optimization algorithm) help in compiling the Keras model?

A

Both by updating network weights iteratively based on training data by diagonal rescaling of the gradients

47
Q

How does regularization help build generalizable models ?

A

By adding dropout layers to our neural networks

48
Q

Select the correct statement regarding the Keras Functional API.

A

Unlike the Keras Sequential API, we have to provide the shape of the input to the model.

49
Q

True//False.
Non-linearity helps in training your model at a much faster rate and with more accuracy without the loss of your important information?

A

True

50
Q

During the training process, each additional layer in your network can successively reduce signal vs. noise. How can we fix this?

A

Use non-saturating, nonlinear activation functions such as ReLUs.

51
Q

Describe a common practice for sending training jobs to Vertex AI

A

When sending training jobs to Vertex AI, it’s common to split most of the logic into a task.py file and a model.py file.

52
Q

What task.py is for when used for sending training jobs to Vertex AI?

A

Task.py is the entry point to your code that Vertex AI will start and knows job-level details like
- how to parse the command line arguments,
- how to long run,
- where to write the outputs,
- how to interface with the hyperparameter tuning
- and so on.

To do core ML, task.py will invoke model.py

53
Q

List nessesary steps To make the code compatible with Vertex AI.

A
  • upload the data to Google Cloud Storage,
  • move the code into a trainer Python package,
  • submit the training job with gcloud to train on Vertex AI.