{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "fc19fea3-7fe9-48e5-b38b-fecafe80b3f9",
   "metadata": {},
   "source": [
    "## Séquençage des données météo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "cd8f796e-ece2-46f3-bb02-34bb00389122",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[32m[I 2022-01-02 16:00:37,511]\u001b[0m A new study created in memory with name: no-name-8511aaee-62c2-4af4-b879-4b5950db28da\u001b[0m\n",
      "2022-01-02 16:00:37.569309: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:937] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero\n",
      "2022-01-02 16:00:37.576764: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/emilesib/ros2_foxy/install/rosbag2_transport/lib:/home/emilesib/ros2_foxy/install/rosbag2_compression/lib:/home/emilesib/ros2_foxy/install/zstd_vendor/lib:/home/emilesib/ros2_foxy/install/rviz_default_plugins/lib:/home/emilesib/ros2_foxy/install/rviz_common/lib:/home/emilesib/ros2_foxy/install/rosbag2_storage_default_plugins/lib:/home/emilesib/ros2_foxy/install/rosbag2_converter_default_plugins/lib:/home/emilesib/ros2_foxy/install/rosbag2_cpp/lib:/home/emilesib/ros2_foxy/install/rosbag2_storage/lib:/home/emilesib/ros2_foxy/install/yaml_cpp_vendor/opt/yaml_cpp_vendor/lib:/home/emilesib/ros2_foxy/install/interactive_markers/lib:/home/emilesib/ros2_foxy/install/visualization_msgs/lib:/home/emilesib/ros2_foxy/install/robot_state_publisher/lib:/home/emilesib/ros2_foxy/install/kdl_parser/lib:/home/emilesib/ros2_foxy/install/urdf/lib:/home/emilesib/ros2_foxy/install/urdfdom/lib:/home/emilesib/ros2_foxy/install/turtlesim/lib:/home/emilesib/ros2_foxy/install/tf2_bullet/lib:/home/emilesib/ros2_foxy/install/tf2_ros/lib:/home/emilesib/ros2_foxy/install/tf2_msgs/lib:/home/emilesib/ros2_foxy/install/test_msgs/lib:/home/emilesib/ros2_foxy/install/demo_nodes_cpp/lib:/home/emilesib/ros2_foxy/install/composition/lib:/home/emilesib/ros2_foxy/install/rclpy/lib:/home/emilesib/ros2_foxy/install/action_tutorials_cpp/lib:/home/emilesib/ros2_foxy/install/rclcpp_action/lib:/home/emilesib/ros2_foxy/install/rcl_action/lib:/home/emilesib/ros2_foxy/install/move_base_msgs/lib:/home/emilesib/ros2_foxy/install/example_interfaces/lib:/home/emilesib/ros2_foxy/install/action_tutorials_interfaces/lib:/home/emilesib/ros2_foxy/install/action_msgs/lib:/home/emilesib/ros2_foxy/install/unique_identifier_msgs/lib:/home/emilesib/ros2_foxy/install/trajectory_msgs/lib:/home/emilesib/ros2_foxy/install/rqt_gui_cpp/lib:/home/emilesib/ros2_foxy/install/rclcpp_lifecycle/lib:/home/emilesib/ros2_foxy/install/logging_demo/lib:/home/emilesib/ros2_foxy/install/image_tools/lib:/home/emilesib/ros2_foxy/install/examples_rclcpp_minimal_composition/lib:/home/emilesib/ros2_foxy/install/demo_nodes_cpp_native/lib:/home/emilesib/ros2_foxy/install/rclcpp_components/lib:/home/emilesib/ros2_foxy/install/laser_geometry/lib:/home/emilesib/ros2_foxy/install/rclcpp/lib:/home/emilesib/ros2_foxy/install/rcl_lifecycle/lib:/home/emilesib/ros2_foxy/install/libstatistics_collector/lib:/home/emilesib/ros2_foxy/install/rcl/lib:/home/emilesib/ros2_foxy/install/tracetools/lib:/home/emilesib/ros2_foxy/install/tlsf/lib:/home/emilesib/ros2_foxy/install/qt_gui_cpp/lib:/home/emilesib/ros2_foxy/install/tf2_eigen_kdl/lib:/home/emilesib/ros2_foxy/install/tf2/lib:/home/emilesib/ros2_foxy/install/stereo_msgs/lib:/home/emilesib/ros2_foxy/install/std_srvs/lib:/home/emilesib/ros2_foxy/install/shape_msgs/lib:/home/emilesib/ros2_foxy/install/map_msgs/lib:/home/emilesib/ros2_foxy/install/sensor_msgs/lib:/home/emilesib/ros2_foxy/install/nav_msgs/lib:/home/emilesib/ros2_foxy/install/diagnostic_msgs/lib:/home/emilesib/ros2_foxy/install/geometry_msgs/lib:/home/emilesib/ros2_foxy/install/actionlib_msgs/lib:/home/emilesib/ros2_foxy/install/std_msgs/lib:/home/emilesib/ros2_foxy/install/statistics_msgs/lib:/home/emilesib/ros2_foxy/install/rcl_logging_spdlog/lib:/home/emilesib/ros2_foxy/install/spdlog_vendor/lib:/home/emilesib/ros2_foxy/install/rviz_rendering/lib:/home/emilesib/ros2_foxy/install/rviz_ogre_vendor/opt/rviz_ogre_vendor/lib:/home/emilesib/ros2_foxy/install/rttest/lib:/home/emilesib/ros2_foxy/install/rosgraph_msgs/lib:/home/emilesib/ros2_foxy/install/rmw_implementation/lib:/home/emilesib/ros2_foxy/install/rmw_fastrtps_dynamic_cpp/lib:/home/emilesib/ros2_foxy/install/rmw_fastrtps_cpp/lib:/home/emilesib/ros2_foxy/install/rmw_fastrtps_shared_cpp/lib:/home/emilesib/ros2_foxy/install/rmw_cyclonedds_cpp/lib:/home/emilesib/ros2_foxy/install/rmw_dds_common/lib:/home/emilesib/ros2_foxy/install/composition_interfaces/lib:/home/emilesib/ros2_foxy/install/rcl_interfaces/lib:/home/emilesib/ros2_foxy/install/pendulum_msgs/lib:/home/emilesib/ros2_foxy/install/lifecycle_msgs/lib:/home/emilesib/ros2_foxy/install/builtin_interfaces/lib:/home/emilesib/ros2_foxy/install/rosidl_typesupport_cpp/lib:/home/emilesib/ros2_foxy/install/rosidl_typesupport_introspection_cpp/lib:/home/emilesib/ros2_foxy/install/rosidl_typesupport_c/lib:/home/emilesib/ros2_foxy/install/rosidl_typesupport_introspection_c/lib:/home/emilesib/ros2_foxy/install/rosidl_typesupport_fastrtps_c/lib:/home/emilesib/ros2_foxy/install/rosidl_typesupport_fastrtps_cpp/lib:/home/emilesib/ros2_foxy/install/rmw/lib:/home/emilesib/ros2_foxy/install/rosidl_runtime_c/lib:/home/emilesib/ros2_foxy/install/resource_retriever/lib:/home/emilesib/ros2_foxy/install/class_loader/lib:/home/emilesib/ros2_foxy/install/rcpputils/lib:/home/emilesib/ros2_foxy/install/rcl_logging_noop/lib:/home/emilesib/ros2_foxy/install/rcl_logging_log4cxx/lib:/home/emilesib/ros2_foxy/install/rcutils/lib:/home/emilesib/ros2_foxy/install/rcl_yaml_param_parser/lib:/home/emilesib/ros2_foxy/install/performance_test_fixture/lib:/home/emilesib/ros2_foxy/install/osrf_testing_tools_cpp/lib:/home/emilesib/ros2_foxy/install/orocos_kdl/lib:/home/emilesib/ros2_foxy/install/mimick_vendor/lib:/home/emilesib/ros2_foxy/install/message_filters/lib:/home/emilesib/ros2_foxy/install/libyaml_vendor/lib:/home/emilesib/ros2_foxy/install/google_benchmark_vendor/lib:/home/emilesib/ros2_foxy/install/fastrtps/lib:/home/emilesib/ros2_foxy/install/fastcdr/lib:/home/emilesib/ros2_foxy/install/cyclonedds/lib:/home/emilesib/ros2_foxy/install/console_bridge_vendor/lib:/home/emilesib/ros2_foxy/install/ament_index_cpp/lib\n",
      "2022-01-02 16:00:37.576781: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.\n",
      "Skipping registering GPU devices...\n",
      "2022-01-02 16:00:37.577354: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA\n",
      "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
      "2022-01-02 16:00:37.713668: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/5\n",
      "79/79 [==============================] - 5s 44ms/step - loss: 0.6557 - binary_crossentropy: 0.6557 - mse: 0.0153\n",
      "Epoch 2/5\n",
      "79/79 [==============================] - 3s 44ms/step - loss: 0.6400 - binary_crossentropy: 0.6400 - mse: 0.0078\n",
      "Epoch 3/5\n",
      "79/79 [==============================] - 3s 43ms/step - loss: 0.6390 - binary_crossentropy: 0.6390 - mse: 0.0074\n",
      "Epoch 4/5\n",
      "79/79 [==============================] - 3s 43ms/step - loss: 0.6383 - binary_crossentropy: 0.6383 - mse: 0.0070\n",
      "Epoch 5/5\n",
      "79/79 [==============================] - 3s 44ms/step - loss: 0.6378 - binary_crossentropy: 0.6378 - mse: 0.0068\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[32m[I 2022-01-02 16:01:57,291]\u001b[0m Trial 0 finished with value: 2.1585139056139586 and parameters: {'len_seq': 158, 'hidden': 46}. Best is trial 0 with value: 2.1585139056139586.\u001b[0m\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "215.85139056139587\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 36088 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 40912 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 38164 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import os\n",
    "import optuna\n",
    "os.chdir('RNN_prediction_meteo')\n",
    "from training import objectif\n",
    "study = optuna.create_study()\n",
    "study.optimize(objectif, n_trials=1) #Plus d'éssaies on étés effectués\n",
    "os.chdir('..')\n",
    "# Les images sont alors dans le dossier RNN_prediction_meteo/images"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6dfdbc98-dac3-45d2-b735-89f8cf2f7890",
   "metadata": {},
   "source": [
    "## Séquençage du wilshire5000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8c036bae-2e48-406c-955a-13bdc770ae42",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[32m[I 2022-01-02 16:02:11,518]\u001b[0m A new study created in memory with name: no-name-cd298f89-e9af-4fbf-8504-de5a85895628\u001b[0m\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/5\n",
      "298/298 [==============================] - 26s 82ms/step - loss: 0.4584 - binary_crossentropy: 0.4584 - mse: 0.0074\n",
      "Epoch 2/5\n",
      "298/298 [==============================] - 25s 83ms/step - loss: 0.4390 - binary_crossentropy: 0.4390 - mse: 2.8698e-04\n",
      "Epoch 3/5\n",
      "298/298 [==============================] - 25s 83ms/step - loss: 0.4386 - binary_crossentropy: 0.4386 - mse: 1.6284e-04\n",
      "Epoch 4/5\n",
      "298/298 [==============================] - 25s 84ms/step - loss: 0.4383 - binary_crossentropy: 0.4383 - mse: 8.0718e-05\n",
      "Epoch 5/5\n",
      "298/298 [==============================] - 25s 85ms/step - loss: 0.4383 - binary_crossentropy: 0.4383 - mse: 7.3841e-05\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\u001b[32m[I 2022-01-02 16:09:05,952]\u001b[0m Trial 0 finished with value: 96.30532998284268 and parameters: {'len_seq': 176, 'hidden': 106}. Best is trial 0 with value: 96.30532998284268.\u001b[0m\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9630.532998284269\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 18220 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 20348 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "[encoded data, 17604 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "os.chdir('RNN_wilshire_5000')\n",
    "from training import objectif\n",
    "study = optuna.create_study()\n",
    "study.optimize(objectif, n_trials=1)#Plus d'éssaies on étés effectués\n",
    "os.chdir('..')\n",
    "# Les images sont alors dans le dossier RNN_wilshire_5000/images"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
