Saturday, 31 August 2019

python machine learning 1

download and install anaconda
https://www.anaconda.com/distribution/

-------------------------------------
//command prompt

Microsoft Windows [Version 10.0.18362.295]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\bob>conda
usage: conda-script.py [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    clean        Remove unused packages and caches.
    config       Modify configuration values in .condarc. This is modeled
                 after the git config command. Writes to the user .condarc
                 file (C:\Users\bob\.condarc) by default.
    create       Create a new conda environment from a list of specified
                 packages.
    help         Displays a list of available conda commands and their help
                 strings.
    info         Display information about current conda install.
    init         Initialize conda for shell interaction. [Experimental]
    install      Installs a list of packages into a specified conda
                 environment.
    list         List linked packages in a conda environment.
    package      Low-level conda package utility. (EXPERIMENTAL)
    remove       Remove a list of packages from a specified conda environment.
    uninstall    Alias for conda remove.
    run          Run an executable in a conda environment. [Experimental]
    search       Search for packages and display associated information. The
                 input is a MatchSpec, a query language for conda packages.
                 See examples below.
    update       Updates conda packages to the latest compatible version.
    upgrade      Alias for conda update.

optional arguments:
  -h, --help     Show this help message and exit.
  -V, --version  Show the conda version number and exit.

conda commands available from other packages:
  build
  convert
  debug
  develop
  env
  index
  inspect
  metapackage
  render
  server
  skeleton
  verify

C:\Users\bob>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-Z plus Return to exit
>>> exit()

C:\Users\bob>conda create -n tensor
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.7.10
  latest version: 4.7.11

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: C:\Users\bob\Anaconda3\envs\tensor



Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate tensor
#
# To deactivate an active environment, use
#
#     $ conda deactivate


C:\Users\bob>conda activate tensor

(tensor) C:\Users\bob>pip install tensorflow
Collecting tensorflow
  Downloading https://files.pythonhosted.org/packages/f7/08/25e47a53692c2e0dcd2211a493ddfe9007a5cd92e175d6dffa6169a0b392/tensorflow-1.14.0-cp37-cp37m-win_amd64.whl (68.3MB)
     |████████████████████████████████| 68.3MB 2.2MB/s
Collecting google-pasta>=0.1.6 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/d0/33/376510eb8d6246f3c30545f416b2263eee461e40940c2a4413c711bdf62d/google_pasta-0.1.7-py3-none-any.whl (52kB)
     |████████████████████████████████| 61kB 1.3MB/s
Collecting keras-preprocessing>=1.0.5 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/28/6a/8c1f62c37212d9fc441a7e26736df51ce6f0e38455816445471f10da4f0a/Keras_Preprocessing-1.1.0-py2.py3-none-any.whl (41kB)
     |████████████████████████████████| 51kB 1.1MB/s
Collecting wrapt>=1.11.1 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/23/84/323c2415280bc4fc880ac5050dddfb3c8062c2552b34c2e512eb4aa68f79/wrapt-1.11.2.tar.gz
Collecting astor>=0.6.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/d1/4f/950dfae467b384fc96bc6469de25d832534f6b4441033c39f914efd13418/astor-0.8.0-py2.py3-none-any.whl
Collecting grpcio>=1.8.6 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/32/e7/478737fd426798caad32a2abb7cc63ddb4c12908d9e03471dd3c41992b05/grpcio-1.23.0-cp37-cp37m-win_amd64.whl (1.6MB)
     |████████████████████████████████| 1.6MB 6.4MB/s
Requirement already satisfied: six>=1.10.0 in c:\users\bob\appdata\roaming\python\python37\site-packages (from tensorflow) (1.12.0)
Collecting absl-py>=0.7.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/3c/0d/7cbf64cac3f93617a2b6b079c0182e4a83a3e7a8964d3b0cc3d9758ba002/absl-py-0.8.0.tar.gz (102kB)
     |████████████████████████████████| 112kB 119kB/s
Collecting protobuf>=3.6.1 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/46/8b/5e77963dac4a944a0c6b198c004fac4c85d7adc54221c288fc6ca9078072/protobuf-3.9.1-cp37-cp37m-win_amd64.whl (1.0MB)
     |████████████████████████████████| 1.0MB 1.3MB/s
Collecting tensorflow-estimator<1.15.0rc0,>=1.14.0rc0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/3c/d5/21860a5b11caf0678fbc8319341b0ae21a07156911132e0e71bffed0510d/tensorflow_estimator-1.14.0-py2.py3-none-any.whl (488kB)
     |████████████████████████████████| 491kB 6.4MB/s
Collecting tensorboard<1.15.0,>=1.14.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/91/2d/2ed263449a078cd9c8a9ba50ebd50123adf1f8cfbea1492f9084169b89d9/tensorboard-1.14.0-py3-none-any.whl (3.1MB)
     |████████████████████████████████| 3.2MB 2.2MB/s
Requirement already satisfied: wheel>=0.26 in c:\users\bob\anaconda3\lib\site-packages (from tensorflow) (0.33.4)
Requirement already satisfied: numpy<2.0,>=1.14.5 in c:\users\bob\anaconda3\lib\site-packages (from tensorflow) (1.16.4)
Collecting gast>=0.2.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/4e/35/11749bf99b2d4e3cceb4d55ca22590b0d7c2c62b9de38ac4a4a7f4687421/gast-0.2.2.tar.gz
Collecting termcolor>=1.1.0 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting keras-applications>=1.0.6 (from tensorflow)
  Downloading https://files.pythonhosted.org/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl (50kB)
     |████████████████████████████████| 51kB 3.4MB/s
Requirement already satisfied: setuptools in c:\users\bob\anaconda3\lib\site-packages (from protobuf>=3.6.1->tensorflow) (41.0.1)
Collecting markdown>=2.6.8 (from tensorboard<1.15.0,>=1.14.0->tensorflow)
  Downloading https://files.pythonhosted.org/packages/c0/4e/fd492e91abdc2d2fcb70ef453064d980688762079397f779758e055f6575/Markdown-3.1.1-py2.py3-none-any.whl (87kB)
     |████████████████████████████████| 92kB 1.5MB/s
Requirement already satisfied: werkzeug>=0.11.15 in c:\users\bob\anaconda3\lib\site-packages (from tensorboard<1.15.0,>=1.14.0->tensorflow) (0.15.4)
Requirement already satisfied: h5py in c:\users\bob\anaconda3\lib\site-packages (from keras-applications>=1.0.6->tensorflow) (2.9.0)
Building wheels for collected packages: wrapt, absl-py, gast, termcolor
  Building wheel for wrapt (setup.py) ... done
  Stored in directory: C:\Users\bob\AppData\Local\pip\Cache\wheels\d7\de\2e\efa132238792efb6459a96e85916ef8597fcb3d2ae51590dfd
  Building wheel for absl-py (setup.py) ... done
  Stored in directory: C:\Users\bob\AppData\Local\pip\Cache\wheels\9a\1e\7a\456008eb5e47fd5de792c6139df6d5b3d5f71d51c6a0b94799
  Building wheel for gast (setup.py) ... done
  Stored in directory: C:\Users\bob\AppData\Local\pip\Cache\wheels\5c\2e\7e\a1d4d4fcebe6c381f378ce7743a3ced3699feb89bcfbdadadd
  Building wheel for termcolor (setup.py) ... done
  Stored in directory: C:\Users\bob\AppData\Local\pip\Cache\wheels\7c\06\54\bc84598ba1daf8f970247f550b175aaaee85f68b4b0c5ab2c6
Successfully built wrapt absl-py gast termcolor
Installing collected packages: google-pasta, keras-preprocessing, wrapt, astor, grpcio, absl-py, protobuf, tensorflow-estimator, markdown, tensorboard, gast, termcolor, keras-applications, tensorflow
  Found existing installation: wrapt 1.10.11
    Uninstalling wrapt-1.10.11:
      Successfully uninstalled wrapt-1.10.11
Successfully installed absl-py-0.8.0 astor-0.8.0 gast-0.2.2 google-pasta-0.1.7 grpcio-1.23.0 keras-applications-1.0.8 keras-preprocessing-1.1.0 markdown-3.1.1 protobuf-3.9.1 tensorboard-1.14.0 tensorflow-1.14.0 tensorflow-estimator-1.14.0 termcolor-1.1.0 wrapt-1.11.2

(tensor) C:\Users\bob>pip install keras
Collecting keras
  Downloading https://files.pythonhosted.org/packages/f8/ba/2d058dcf1b85b9c212cc58264c98a4a7dd92c989b798823cc5690d062bb2/Keras-2.2.5-py2.py3-none-any.whl (336kB)
     |████████████████████████████████| 337kB 1.1MB/s
Requirement already satisfied: h5py in c:\users\bob\anaconda3\lib\site-packages (from keras) (2.9.0)
Requirement already satisfied: numpy>=1.9.1 in c:\users\bob\anaconda3\lib\site-packages (from keras) (1.16.4)
Requirement already satisfied: keras-applications>=1.0.8 in c:\users\bob\anaconda3\lib\site-packages (from keras) (1.0.8)
Requirement already satisfied: keras-preprocessing>=1.1.0 in c:\users\bob\anaconda3\lib\site-packages (from keras) (1.1.0)
Requirement already satisfied: pyyaml in c:\users\bob\anaconda3\lib\site-packages (from keras) (5.1.1)
Requirement already satisfied: six>=1.9.0 in c:\users\bob\appdata\roaming\python\python37\site-packages (from keras) (1.12.0)
Requirement already satisfied: scipy>=0.14 in c:\users\bob\anaconda3\lib\site-packages (from keras) (1.2.1)
Installing collected packages: keras
Successfully installed keras-2.2.5

(tensor) C:\Users\bob>

---------------------------------------
#pycharm

create new project -> enter project name -> click file -> settings -> project interpreter -> click gear icon -> add -> conda environment -> existing environment -> click 3 dot icon ->  change path to c:/users/(username)/Anaconda3/pythonw.exe -> ok -> apply -> waiting for package update to finish -> create new python file -> type import tensorflow, should have no error -> click add configration (top right)-> click + -> python -> name configuration -> change script path to project path/(name).py -> apply ok

-------------------------------
reference:
https://www.youtube.com/watch?v=ujTCoH21GlA

No comments:

Post a Comment