-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 35113f3
Showing
9,634 changed files
with
1,913,684 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "eigen-git-mirror"] | ||
path = eigen | ||
url = https://github.com/eigenteam/eigen-git-mirror | ||
[submodule "pybind11"] | ||
path = pybind11 | ||
url = https://github.com/pybind/pybind11 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(tp2) | ||
|
||
set (CMAKE_CXX_STANDARD 11) | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") | ||
|
||
|
||
IF(CMAKE_BUILD_TYPE MATCHES Debug) | ||
message("Debug mode") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -O0") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") | ||
ENDIF() | ||
|
||
IF(CMAKE_BUILD_TYPE MATCHES Release) | ||
message("Release mode") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") | ||
ENDIF() | ||
|
||
# si se usa un virtual environment setearlo aca | ||
#set(PYTHON_EXECUTABLE "/path/to/bin/python") | ||
#set(PYTHON_LIBRARY "/path/to/lib/libpytho.so") | ||
|
||
# Prender y apagar este flag para soporte OpenMP | ||
#set(USE_OpenMP ON) | ||
# Script cmake ``multi-plataforma`` (testeado en MacOS y Ubuntu) | ||
#include(cmake/OpenMP.cmake) | ||
|
||
include_directories(eigen) | ||
|
||
add_subdirectory(pybind11) | ||
|
||
pybind11_add_module(metnum | ||
src/metnum.cpp | ||
src/knn.cpp | ||
src/pca.cpp | ||
src/eigen.cpp) | ||
|
||
# Por cada módulo que use OpenMP ponerlo como dependencia de esta forma | ||
#target_link_libraries(metnum LINK_PUBLIC OpenMP::OpenMP_CXX) | ||
|
||
# Esta variable se usa para fijar el directorio de instalación | ||
set(CMAKE_INSTALL_PREFIX | ||
${PROJECT_SOURCE_DIR} | ||
CACHE PATH "Python custom modules directory" FORCE) | ||
|
||
message(CMAKE_INSTALL_PREFIX = "${CMAKE_INSTALL_PREFIX}") | ||
|
||
install(TARGETS metnum DESTINATION ${CMAKE_INSTALL_PREFIX}/notebooks) | ||
|
||
# Crear un binario para testing manteniendo las dependencias de python por separado | ||
add_executable(tp2 | ||
src/main.cpp | ||
src/knn.cpp | ||
src/pca.cpp | ||
src/eigen.cpp) | ||
|
||
|
||
# si se quiere hacer un ejecutable "tp2" que incluya pybind11, utilizar las | ||
# siguientes 3 instrucciones de cmake. | ||
|
||
#include_directories(pybind11/include) | ||
|
||
#add_executable(tp2_pybind | ||
# src/main_pybind.cpp | ||
# src/knn.cpp | ||
# src/pca.cpp | ||
# src/eigen.cpp) | ||
# | ||
#target_link_libraries(tp2_pybind PRIVATE pybind11::embed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Reconocimiento de dígitos: TP2 de Métodos Numéricos | ||
## 2021, 2do cuatrimestre | ||
|
||
## Instrucciones | ||
|
||
|
||
1. Crear un repo git en donde se bajen esto | ||
|
||
``` | ||
git init | ||
git remote add origin <nuestra-nueva-url-de-git> | ||
``` | ||
|
||
2. Bajarse los repositorios de `pybind` y `eigen` como submódulos | ||
|
||
``` | ||
git submodule init | ||
git submodule add https://github.com/eigenteam/eigen-git-mirror | ||
git submodule add https://github.com/pybind/pybind11 | ||
git mv eigen-git-mirror eigen | ||
# Elegimos versiones de eigen y pybind | ||
cd pybind11/ && git checkout v2.2.4 && cd .. | ||
cd eigen && git checkout 3.3.7 && cd .. | ||
``` | ||
|
||
3. Instalar requerimientos (*Previamente activar el entorno virtual. Ver más abajo*) | ||
|
||
``` | ||
pip install -r requirements.txt | ||
``` | ||
|
||
4. Descomprimir datos | ||
|
||
``` | ||
cd data && gunzip *.gz && cd .. | ||
``` | ||
|
||
5. Correr Jupyter | ||
|
||
``` | ||
jupyter lab | ||
``` | ||
|
||
Listo. Ya pueden disfrutar del TP2 | ||
|
||
### Datos | ||
|
||
En `data/` tenemos los datos de entrenamiento (`data/train.csv`) y los de test (`data/test.csv`). | ||
|
||
### Otros directorios | ||
|
||
En `src/` está el código de C++, en particular en `src/metnum.cpp` está el entry-point de pybind. | ||
|
||
En `notebooks/` hay ejemplos para correr partes del TP usando sklearn y usando la implementación en C++. | ||
|
||
|
||
## Creación de un entorno virtual de python | ||
|
||
### Con pyenv | ||
|
||
``` | ||
curl https://pyenv.run | bash | ||
``` | ||
|
||
Luego, se sugiere agregar unas líneas al bashrc. Hacer eso, **REINICIAR LA CONSOLA** y luego... | ||
|
||
``` | ||
pyenv install 3.6.5 | ||
pyenv global 3.6.5 | ||
pyenv virtualenv 3.6.5 tp2 | ||
``` | ||
|
||
En el directorio del proyecto | ||
|
||
``` | ||
pyenv activate tp2 | ||
``` | ||
|
||
### Directamente con python3 | ||
``` | ||
python3 -m venv tp2 | ||
source tp2/bin/activate | ||
``` | ||
|
||
### Con Conda | ||
``` | ||
conda create --name tp2 python=3.6.5 | ||
conda activate tp2 | ||
``` | ||
|
||
## Instalación de las depencias | ||
``` | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Correr notebooks de jupyter | ||
|
||
``` | ||
cd notebooks | ||
jupyter lab | ||
``` | ||
o notebook | ||
``` | ||
jupyter notebook | ||
``` | ||
|
||
|
||
## Compilación | ||
Ejecutar la primera celda del notebook `knn.ipynb` o seguir los siguientes pasos: | ||
|
||
|
||
- Compilar el código C++ en un módulo de python | ||
``` | ||
mkdir build | ||
cd build | ||
rm -rf * | ||
cmake -DPYTHON_EXECUTABLE="$(which python)" -DCMAKE_BUILD_TYPE=Release .. | ||
``` | ||
- Al ejecutar el siguiente comando se compila e instala la librería en el directorio `notebooks` | ||
``` | ||
make install | ||
``` |
Oops, something went wrong.