{ "info": { "author": "nethub", "author_email": "nethub@yandex.ru", "bugtrack_url": null, "classifiers": [], "description": "# NetPy\n\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/maclinchy/netpy/blob/master/LICENSE)\n\n## Installation\n\n### We recommended to install NetPy in virtual env.\nTo get started, you should install ```virtualenv``` tool with ```pip```.\n\n```sh\npip install virtualenv\n```\nNew directory to work with:\n```sh\nmkdir python-virtual-environments && cd python-virtual-environments\n```\nCreate a new virtual environment inside the directory:\n```sh\npython -m venv netpy_env\n```\nYou need to \"activate\" it.\n```sh\nsource netpy_env/bin/activate\n```\nIf your system is windows:\n```sh\nnetpy_env\\Scripts\\activate\n```\n\nThen you need to install NetPy. There is two ways to install:\n\n- **Install NetPy from PyPI (recommended):**\n\n```sh\nsudo pip install netpy\n```\n\n- **Install NetPy from GitHub source:**\n\n```sh\ngit clone https://github.com/maclinchy/netpy.git\ncd netpy\nsudo python setup.py install\n```\n\n------------------\n## Getting started\n\nLet's create the net:\n```sh\nnhm newnet myFirstNet\n```\n\n`netpy-manager` will create folder `myFirstNet`, which contains a directory structure similar to this:\n\n```sh\n\u251c\u2500\u2500 data_set\n\u2502 \u251c\u2500\u2500 data_X.txt\n\u2502 \u2514\u2500\u2500 data_Y.txt\n\u251c\u2500\u2500 net_data\n\u2502 \u2514\u2500\u2500 arch.json\n\u251c\u2500\u2500 conf.json\n\u251c\u2500\u2500 network.py\n\u251c\u2500\u2500 test.py\n\u2514\u2500\u2500 train.py\n\n```\n\n`data_set` is folder which contains data for learning.\n\n`net_data` is folder which contains data about our net.\n\n`conf.json` is file with settings.\n\n`network.py` is main file for init the net.\n\n`train.py` is file for train the net\n\n`test.py` is file for test the net. \n\nLet's create net with 3 layers.\n------------------\n`network.py`\n```python\nfrom netpy.nets import FeedForwardNet\nfrom netpy.modules import LinearLayer,SigmoidLayer, FullRelation\nfrom netpy.teachers import BackPropTeacher\nimport numpy as np\n\n# Import file with settings\nimport conf\n\nnet = FeedForwardNet()\n\n# Add your layers here\ninput_layer = LinearLayer()\nhidden_layer = SigmoidLayer()\noutput_layer = SigmoidLayer()\n\n# Add your layers to the net here\nnet.add_Input_Layer(input_layer)\nnet.add_Layer(hidden_layer)\nnet.add_Output_Layer(output_layer)\n\n# Add your connections here\nrel_in_hid = FullRelation(input_layer, hidden_layer)\nrel_hid_out = FullRelation(hidden_layer, output_layer)\n\n# Add your connections to the net here\nnet.add_Relation(rel_in_hid)\nnet.add_Relation(rel_hid_out)\n```\n\n`train.py`\n```python\nfrom netpy.teachers import BackPropTeacher\nfrom network import net\nimport numpy as np\nimport conf\n\nnum_of_epoch = 8\n\n# Your data set\ntrain_X = np.loadtxt(conf.data_set_dir_X)\ntrain_Y = np.loadtxt(conf.data_set_dir_Y)\n\n# Config your teacher\nteacher = BackPropTeacher(net,\n error = 'MSE',\n learning_rate = 1e-5,\n alpha = 0.0001)\n\n\n# Teach your net here\nteacher.train(X, Y, num_of_epoch, load_data = False)\n```\n\n`test.py`\n```python\n\nfrom network import net\n\ntest = []\n\nnet.load()\n\nprint(net.forward(test))\n```\n\nWe need to add neurons to the net:\n```python\ninput_layer = LinearLayer(3)\nhidden_layer = SigmoidLayer(20)\noutput_layer = SigmoidLayer(1)\n```\n\nThen we need to add the data:\n`data_X.txt`\n```sh\n0 0 0\n0 0 1\n0 1 0\n0 1 1\n1 0 0\n1 0 1\n1 1 0\n1 1 1\n```\n`data_Y.txt`\n```sh\n0\n0\n0\n1\n0\n1\n1\n1\n```\n\nLet's train the net!\n```sh\npython train.py\n```\n\nIn `net_data` two files - `weights.h5` and `arch.json`.\n\n- In `weights.h5` we have save our weights.\n- In `arch.json` we have save data about the net.\n- In `myFirstNet.log` we have history of net's actions.\n\nIf you want to continue learning you should change parameter of train function:\n```python\nteacher.train(X, Y, 100, load_data = True)\n```\n\nLet's test the net!\n\n```sh\npython test.py\n```\n\n`test.py`\n```python\n\nfrom network import net\n\ntest = [0,0,0]\n\nnet.load()\n\nprint(net.forward(test))\n```\n\nYou can fork your net:\n```sh\nnhm fork myFirstNet mySecondNet\n```\n\nYou can rename your net:\n```sh\nnhm rename mySecondNet myAwesomeNet\n```", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "netpy", "package_url": "https://pypi.org/project/netpy/", "platform": "", "project_url": "https://pypi.org/project/netpy/", "project_urls": null, "release_url": "https://pypi.org/project/netpy/0.0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Library for ML", "version": "0.0.0.1" }, "last_serial": 4835702, "releases": { "0.0.0.1": [ { "comment_text": "", "digests": { "md5": "643e381feccb4ebd9d4c754015f45caf", "sha256": "8f9dbdfc82bbf70d19ad4c4c29833ea2ac12b0ca54590ec676ff827ecf71dd9f" }, "downloads": -1, "filename": "netpy-0.0.0.1.tar.gz", "has_sig": false, "md5_digest": "643e381feccb4ebd9d4c754015f45caf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10743, "upload_time": "2019-02-18T15:44:47", "url": "https://files.pythonhosted.org/packages/04/ce/e6ab58716b53d12013132d2cd841b9d5213af024647afe363e8e8c039a94/netpy-0.0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "643e381feccb4ebd9d4c754015f45caf", "sha256": "8f9dbdfc82bbf70d19ad4c4c29833ea2ac12b0ca54590ec676ff827ecf71dd9f" }, "downloads": -1, "filename": "netpy-0.0.0.1.tar.gz", "has_sig": false, "md5_digest": "643e381feccb4ebd9d4c754015f45caf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10743, "upload_time": "2019-02-18T15:44:47", "url": "https://files.pythonhosted.org/packages/04/ce/e6ab58716b53d12013132d2cd841b9d5213af024647afe363e8e8c039a94/netpy-0.0.0.1.tar.gz" } ] }