Quiz 1: CS545 Fall 2021

Type your name here:

Type the AI and Machine Learning course names or numbers that you have taken and the semester and year. Format them as a bulleted list, as shown. if you have taken relevant courses at other colleges, describe them here.

For example:

  • CS445, Spring, 2021

Have you used jupyter notebooks before? If yes, please briefly describe what you used them for.

<type your answer here>

Which editor do you like to use for writing python code?

<type your answer here>

Edit the following list by deleting python packages that you have not used. Add others with which you are familiar.

  • numpy
  • matplotlib
  • scipy
  • sklearn
  • pytorch
  • tensorflow

Complete the following Latex expressions for the derivatives of functions $g$, $h$, and $k$ with respect to $x$.

$$ \begin{align*} f(x) &= x^2 \\ \frac{\partial f(x)}{\partial x} &= 2x \\ ~ \\ g(x) &= \frac{1}{1 + e^{-ax}}\\ \frac{\partial g(x)}{\partial x} &= \text{<replace with your answer>} \\ ~ \\ h(x) &= \tanh(42 x)\\ \frac{\partial h(x)}{\partial x} &= \text{<replace with your answer>} \\ ~ \\ k(x) &= (t - \tanh(z x))^2\\ \frac{\partial k(x)}{\partial x} &= \text{<replace with your answer>} \end{align*} $$

Add a code cell and in it type python statements to define the two matrices, $A$ and $B$, as numpy arrays, print them, and print their shapes.

$$ A = \begin{bmatrix} 1 & 2 & 3\\ 4 & 5 & 6 \end{bmatrix} \;\;\; \text{ and } \;\;\; B = \begin{bmatrix} 10 & 20 \\ 30 & 40 \\ 50 & 60 \end{bmatrix} $$

Add another code cell here and write python statements to multiply $A$ and $B$ and print the answer.

Add a code cell and write python statements that show $$ (A B)^T = B^T A^T$$

In another code cell, define a numpy array in variable $x$ of 20 values equally spaced from $-10$ to 10 using np.linspace. Then plot $\tanh(x)$ versus $x$ using the matplotlib package.

The following code cell defines a list of integers. Write one line of python that uses a list comprehension to square each value of the original list.

In [ ]:
x = [1, 5, 15, 3, -42]
x_squared = 
x, x_squared

In another code cell, use np.stack and the transpose operator to combine x and x_squared into one numpy array of two columns with the first value in each row from x and the second value in the same row the value of x squared. Display the result.

In another code cell, make a plot of x_squared values versus x values, using the 'o' style.

How many hours did it take you to complete this quiz?

<type your answer here>

When you are done, save this notebook and submit it through our course Canvas webpage.