{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Graded Exercise Session 1: Preparation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### To make sure you already have necessary libraries installed, please execute the following import statements. " ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt \n", "import cv2\n", "import scipy\n", "import skimage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### If you have any missing libraries\n", "\n", "You can install libraries individually using conda OR if you want to create a new environment with all the necessary libraries,\n", "\n", "- Create a new conda environment: ```conda create -n cv2019 python=3.7 matplotlib opencv scikit-image jupyter```\n", "- Activate it: ```conda activate cv2019```\n", "- Launch jupyter notebook: ```jupyter-notebook```\n", "\n", "#### If you haven't installed python yet\n", "- Install python: https://www.anaconda.com/distribution/ (download python 3.7)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### To find the documentation of a function, you can use ```help``` function" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function sum in module numpy.core.fromnumeric:\n", "\n", "sum(a, axis=None, dtype=None, out=None, keepdims=, initial=)\n", " Sum of array elements over a given axis.\n", " \n", " Parameters\n", " ----------\n", " a : array_like\n", " Elements to sum.\n", " axis : None or int or tuple of ints, optional\n", " Axis or axes along which a sum is performed. The default,\n", " axis=None, will sum all of the elements of the input array. If\n", " axis is negative it counts from the last to the first axis.\n", " \n", " .. versionadded:: 1.7.0\n", " \n", " If axis is a tuple of ints, a sum is performed on all of the axes\n", " specified in the tuple instead of a single axis or all the axes as\n", " before.\n", " dtype : dtype, optional\n", " The type of the returned array and of the accumulator in which the\n", " elements are summed. The dtype of `a` is used by default unless `a`\n", " has an integer dtype of less precision than the default platform\n", " integer. In that case, if `a` is signed then the platform integer\n", " is used while if `a` is unsigned then an unsigned integer of the\n", " same precision as the platform integer is used.\n", " out : ndarray, optional\n", " Alternative output array in which to place the result. It must have\n", " the same shape as the expected output, but the type of the output\n", " values will be cast if necessary.\n", " keepdims : bool, optional\n", " If this is set to True, the axes which are reduced are left\n", " in the result as dimensions with size one. With this option,\n", " the result will broadcast correctly against the input array.\n", " \n", " If the default value is passed, then `keepdims` will not be\n", " passed through to the `sum` method of sub-classes of\n", " `ndarray`, however any non-default value will be. If the\n", " sub-class' method does not implement `keepdims` any\n", " exceptions will be raised.\n", " initial : scalar, optional\n", " Starting value for the sum. See `~numpy.ufunc.reduce` for details.\n", " \n", " .. versionadded:: 1.15.0\n", " \n", " Returns\n", " -------\n", " sum_along_axis : ndarray\n", " An array with the same shape as `a`, with the specified\n", " axis removed. If `a` is a 0-d array, or if `axis` is None, a scalar\n", " is returned. If an output array is specified, a reference to\n", " `out` is returned.\n", " \n", " See Also\n", " --------\n", " ndarray.sum : Equivalent method.\n", " \n", " cumsum : Cumulative sum of array elements.\n", " \n", " trapz : Integration of array values using the composite trapezoidal rule.\n", " \n", " mean, average\n", " \n", " Notes\n", " -----\n", " Arithmetic is modular when using integer types, and no error is\n", " raised on overflow.\n", " \n", " The sum of an empty array is the neutral element 0:\n", " \n", " >>> np.sum([])\n", " 0.0\n", " \n", " Examples\n", " --------\n", " >>> np.sum([0.5, 1.5])\n", " 2.0\n", " >>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)\n", " 1\n", " >>> np.sum([[0, 1], [0, 5]])\n", " 6\n", " >>> np.sum([[0, 1], [0, 5]], axis=0)\n", " array([0, 6])\n", " >>> np.sum([[0, 1], [0, 5]], axis=1)\n", " array([1, 5])\n", " \n", " If the accumulator is too small, overflow occurs:\n", " \n", " >>> np.ones(128, dtype=np.int8).sum(dtype=np.int8)\n", " -128\n", " \n", " You can also start the sum with a value other than zero:\n", " \n", " >>> np.sum([10], initial=5)\n", " 15\n", "\n" ] } ], "source": [ "help(np.sum)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" } }, "nbformat": 4, "nbformat_minor": 2 }