Newer
Older
rnn_bachelor_thesis / 1_to_1_multi_compact.ipynb
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "c:\\users\\sa_li\\anaconda3\\envs\\rnn-tf-ker\\lib\\site-packages\\h5py\\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n"
     ]
    }
   ],
   "source": [
    "#Here i do all the preprocessing of my data and define my functions and the RNNPlacePrediction class\n",
    "\n",
    "exec(open(\"requiremements.py\").read())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "timesteps = 7\n",
    "future_steps = 1\n",
    "ninputs = 3\n",
    "num_output = 3\n",
    "\n",
    "#ncells as int or list of int\n",
    "ncells = [50, 40, 30, 20, 10]\n",
    "\n",
    "cell_type = \"lstm\"\n",
    "activation = \"leaky_relu\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "tf.reset_default_graph()\n",
    "rnn = RNNPlacePrediction(time_steps=timesteps, future_steps=future_steps, ninputs=ninputs, \n",
    "                        ncells=ncells, num_output=num_output, cell_type=cell_type, activation=activation)\n",
    "rnn.set_cost_and_functions()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch number  0\n",
      "Cost:  373770.60410824226 e-6\n",
      "Patience:  0 / 200\n",
      "Last checkpoint at: Epoch  0 \n",
      "\n",
      "\n",
      "\n",
      "Model saved in at:  ./rnn_model_lstm_leaky_relu_[50,40,30,20,10]c/rnn_basic\n",
      "Model saved at:  ./rnn_model_lstm_leaky_relu_[50,40,30,20,10]c/rnn_basic\n",
      "Remaining data saved as: rnn_model_lstm_leaky_relu_[50,40,30,20,10]c.pkl\n"
     ]
    }
   ],
   "source": [
    "rnn.fit(minibatches, epochs = 5, print_step=5)\n",
    "full_save(rnn)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "#plot_loss_list(loss_list = rnn.loss_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#folder = get_rnn_folder(ncells = ncells, cell_type = \"lstm\", activation = \"leaky_relu\")\n",
    "#rnn, data = full_load(folder)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  0.24988278 -16.92240567 -11.00905584]\n",
      " [ -0.95585176 -19.82122722  -9.62447234]\n",
      " [  2.90237107 -13.03493918 -11.99622082]\n",
      " [ -2.20826846   4.92884641  12.53874474]\n",
      " [-20.9477203   13.2462497   -1.09616262]\n",
      " [-31.69245226   0.34849761   4.28013375]\n",
      " [  0.24281463   5.55824599   3.57549133]]\n",
      "Loss on test set: 0.17207867\n"
     ]
    }
   ],
   "source": [
    "test_pred, test_loss = rnn_test(rnn = rnn)"
   ]
  }
 ],
 "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.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}