Commit 985a4b13 authored by Manuel Günther's avatar Manuel Günther

Moved C++ code into its own Library; removed depencence on Bob

parent 70294bf6
......@@ -14,15 +14,11 @@ matrix:
- NUMPYSPEC===1.8.0
before_install:
- sudo add-apt-repository -y ppa:biometrics/bob
- sudo add-apt-repository -y ppa:biometrics/bob.preview
- sudo apt-get update -qq
- sudo apt-get install -qq --force-yes bob-dev
- if [ -n "${NUMPYSPEC}" ]; then sudo apt-get install -qq libatlas-dev libatlas-base-dev
liblapack-dev gfortran; fi
- sudo apt-get install -qq --force-yes ibboost-all-dev libblitz1-dev libhdf5-serial-dev libatlas-dev libatlas-base-dev liblapack-dev
- if [ -n "${NUMPYSPEC}" ]; then sudo apt-get install -qq gfortran; fi
- if [ -n "${NUMPYSPEC}" ]; then pip install --upgrade pip setuptools; fi
- if [ -n "${NUMPYSPEC}" ]; then pip install --find-links http://wheels.astropy.org/
--find-links http://wheels2.astropy.org/ --use-wheel numpy$NUMPYSPEC sphinx nose;
fi
- if [ -n "${NUMPYSPEC}" ]; then pip install --find-links http://wheels.astropy.org/ --find-links http://wheels2.astropy.org/ --use-wheel numpy$NUMPYSPEC sphinx nose; fi
- pip install cpp-coveralls
install:
- python bootstrap.py
......
......@@ -11,10 +11,10 @@
*/
#include <boost/format.hpp>
#include <bob/math/pinv.h>
#include <bob/math/eig.h>
#include <bob/math/linear.h>
#include <bob/math/stats.h>
#include <bob.math/pinv.h>
#include <bob.math/eig.h>
#include <bob.math/linear.h>
#include <bob.math/stats.h>
#include <bob.learn.linear/lda.h>
......
......@@ -5,8 +5,8 @@
* Copyright (C) Idiap Research Institute, Martigny, Switzerland
*/
#include <bob/core/logging.h>
#include <bob/math/linear.h>
#include <bob.core/logging.h>
#include <bob.math/linear.h>
#include <limits>
#include <bob.learn.linear/logreg.h>
......
......@@ -11,8 +11,8 @@
#include <boost/make_shared.hpp>
#include <boost/format.hpp>
#include <bob/core/array_copy.h>
#include <bob/math/linear.h>
#include <bob.core/array_copy.h>
#include <bob.math/linear.h>
#include <bob.learn.linear/machine.h>
......@@ -22,7 +22,7 @@ namespace bob { namespace learn { namespace linear {
: m_input_sub(weight.extent(0)),
m_input_div(weight.extent(0)),
m_bias(weight.extent(1)),
m_activation(boost::make_shared<bob::machine::IdentityActivation>()),
m_activation(boost::make_shared<bob::learn::activation::IdentityActivation>()),
m_buffer(weight.extent(0))
{
m_input_sub = 0.0;
......@@ -36,7 +36,7 @@ namespace bob { namespace learn { namespace linear {
m_input_div(0),
m_weight(0, 0),
m_bias(0),
m_activation(boost::make_shared<bob::machine::IdentityActivation>()),
m_activation(boost::make_shared<bob::learn::activation::IdentityActivation>()),
m_buffer(0)
{
}
......@@ -46,7 +46,7 @@ namespace bob { namespace learn { namespace linear {
m_input_div(n_input),
m_weight(n_input, n_output),
m_bias(n_output),
m_activation(boost::make_shared<bob::machine::IdentityActivation>()),
m_activation(boost::make_shared<bob::learn::activation::IdentityActivation>()),
m_buffer(n_input)
{
m_input_sub = 0.0;
......@@ -65,7 +65,7 @@ namespace bob { namespace learn { namespace linear {
{
}
Machine::Machine (bob::io::HDF5File& config) {
Machine::Machine (bob::io::base::HDF5File& config) {
load(config);
}
......@@ -106,7 +106,7 @@ namespace bob { namespace learn { namespace linear {
m_activation->str() == b.m_activation->str());
}
void Machine::load (bob::io::HDF5File& config) {
void Machine::load (bob::io::base::HDF5File& config) {
//reads all data directly into the member variables
m_input_sub.reference(config.readArray<double,1>("input_sub"));
......@@ -118,12 +118,12 @@ namespace bob { namespace learn { namespace linear {
//switch between different versions - support for version 1
if (config.hasAttribute(".", "version")) { //new version
config.cd("activation");
m_activation = bob::machine::load_activation(config);
m_activation = bob::learn::activation::load_activation(config);
config.cd("..");
}
else { //old version
uint32_t act = config.read<uint32_t>("activation");
m_activation = bob::machine::make_deprecated_activation(act);
m_activation = bob::learn::activation::make_deprecated_activation(act);
}
}
......@@ -138,7 +138,7 @@ namespace bob { namespace learn { namespace linear {
}
void Machine::save (bob::io::HDF5File& config) const {
void Machine::save (bob::io::base::HDF5File& config) const {
config.setAttribute(".", "version", 1);
config.setArray("input_sub", m_input_sub);
......@@ -226,7 +226,7 @@ namespace bob { namespace learn { namespace linear {
}
void Machine::setActivation (boost::shared_ptr<bob::machine::Activation> a) {
void Machine::setActivation (boost::shared_ptr<bob::learn::activation::Activation> a) {
m_activation = a;
}
......
......@@ -13,9 +13,9 @@
#include <algorithm>
#include <blitz/array.h>
#include <boost/format.hpp>
#include <bob/math/stats.h>
#include <bob/math/svd.h>
#include <bob/math/eig.h>
#include <bob.math/stats.h>
#include <bob.math/svd.h>
#include <bob.math/eig.h>
#include <bob.learn.linear/pca.h>
......
......@@ -7,9 +7,9 @@
*/
#include <boost/make_shared.hpp>
#include <bob/math/inv.h>
#include <bob/math/lu.h>
#include <bob/math/stats.h>
#include <bob.math/inv.h>
#include <bob.math/lu.h>
#include <bob.math/stats.h>
#include <bob.learn.linear/wccn.h>
......@@ -97,7 +97,7 @@ namespace bob { namespace learn { namespace linear {
machine.setInputDivision(1.);
machine.setWeights(buf1);
machine.setBiases(0);
machine.setActivation(boost::make_shared<bob::machine::IdentityActivation>());
machine.setActivation(boost::make_shared<bob::learn::activation::IdentityActivation>());
}
......
......@@ -6,9 +6,9 @@
*/
#include <boost/make_shared.hpp>
#include <bob/math/inv.h>
#include <bob/math/lu.h>
#include <bob/math/stats.h>
#include <bob.math/inv.h>
#include <bob.math/lu.h>
#include <bob.math/stats.h>
#include <bob.learn.linear/whitening.h>
......@@ -84,7 +84,7 @@ namespace bob { namespace learn { namespace linear {
machine.setInputDivision(1.);
machine.setWeights(whiten);
machine.setBiases(0);
machine.setActivation(boost::make_shared<bob::machine::IdentityActivation>());
machine.setActivation(boost::make_shared<bob::learn::activation::IdentityActivation>());
}
}}}
......@@ -15,7 +15,7 @@
#define BOB_LEARN_LINEAR_FISHER_H
#include <vector>
#include "machine.h"
#include <bob.learn.linear/machine.h>
namespace bob { namespace learn { namespace linear {
......
......@@ -12,7 +12,7 @@
#define BOB_LEARN_LINEAR_LOGREG_H
#include <boost/format.hpp>
#include "machine.h"
#include <bob.learn.linear/machine.h>
namespace bob { namespace learn { namespace linear {
......
......@@ -18,8 +18,8 @@
#define BOB_LEARN_LINEAR_MACHINE_H
#include <blitz/array.h>
#include <bob/io/HDF5File.h>
#include <bob/machine/Activation.h>
#include <bob.io.base/HDF5File.h>
#include <bob.learn.activation/Activation.h>
namespace bob { namespace learn { namespace linear {
......@@ -62,7 +62,7 @@ namespace bob { namespace learn { namespace linear {
/**
* Starts a new Machine from an existing Configuration object.
*/
Machine (bob::io::HDF5File& config);
Machine (bob::io::base::HDF5File& config);
/**
* Just to virtualise the destructor
......@@ -92,12 +92,12 @@ namespace bob { namespace learn { namespace linear {
* Loads data from an existing configuration object. Resets the current
* state.
*/
void load (bob::io::HDF5File& config);
void load (bob::io::base::HDF5File& config);
/**
* Saves an existing machine to a Configuration object.
*/
void save (bob::io::HDF5File& config) const;
void save (bob::io::base::HDF5File& config) const;
/**
* Forwards data through the network, outputs the values of each linear
......@@ -247,12 +247,12 @@ namespace bob { namespace learn { namespace linear {
/**
* Returns the currently set activation function
*/
inline boost::shared_ptr<bob::machine::Activation> getActivation() const { return m_activation; }
inline boost::shared_ptr<bob::learn::activation::Activation> getActivation() const { return m_activation; }
/**
* Sets the activation function for each of the outputs.
*/
void setActivation(boost::shared_ptr<bob::machine::Activation> a);
void setActivation(boost::shared_ptr<bob::learn::activation::Activation> a);
private: //representation
......@@ -262,7 +262,7 @@ namespace bob { namespace learn { namespace linear {
blitz::Array<double, 1> m_input_div; ///< input division
blitz::Array<double, 2> m_weight; ///< weights
blitz::Array<double, 1> m_bias; ///< biases for the output
boost::shared_ptr<bob::machine::Activation> m_activation; ///< currently set activation type
boost::shared_ptr<bob::learn::activation::Activation> m_activation; ///< currently set activation type
mutable blitz::Array<double, 1> m_buffer; ///< a buffer for speed
......
......@@ -13,7 +13,7 @@
#ifndef BOB_LEARN_LINEAR_PCA_H
#define BOB_LEARN_LINEAR_PCA_H
#include "machine.h"
#include <bob.learn.linear/machine.h>
namespace bob { namespace learn { namespace linear {
......
......@@ -9,7 +9,7 @@
#ifndef BOB_LEARN_LINEAR_WCCN_H
#define BOB_LEARN_LINEAR_WCCN_H
#include "machine.h"
#include <bob.learn.linear/machine.h>
namespace bob { namespace learn { namespace linear {
......
......@@ -8,7 +8,7 @@
#ifndef BOB_LEARN_LINEAR_WHITENING_H
#define BOB_LEARN_LINEAR_WHITENING_H
#include "machine.h"
#include <bob.learn.linear/machine.h>
namespace bob { namespace learn { namespace linear {
......
......@@ -567,9 +567,7 @@ PyObject* PyBobLearnLinearMachine_Repr(PyBobLearnLinearMachineObject* self) {
* <bob.learn.linear.Machine float64@(3, 2) [act: f(z) = tanh(z)]>
*/
using bob::machine::IdentityActivation;
static const std::string identity_str = IdentityActivation().str();
static const std::string identity_str = bob::learn::activation::IdentityActivation().str();
auto weights = make_safe(PyBobLearnLinearMachine_getWeights(self, 0));
if (!weights) return 0;
......@@ -616,9 +614,7 @@ PyObject* PyBobLearnLinearMachine_Str(PyBobLearnLinearMachineObject* self) {
* [ 0.2 0.7]]
*/
using bob::machine::IdentityActivation;
static const std::string identity_str = IdentityActivation().str();
static const std::string identity_str = bob::learn::activation::IdentityActivation().str();
boost::shared_ptr<PyObject> act;
if (self->cxx->getActivation()->str() != identity_str) {
......
......@@ -5,9 +5,12 @@
* @brief Binds configuration information available from bob
*/
#include <Python.h>
#ifdef NO_IMPORT_ARRAY
#undef NO_IMPORT_ARRAY
#endif
#include <bob.blitz/capi.h>
#include <bob.blitz/cleanup.h>
#include <bob/config.h>
#include <string>
#include <cstdlib>
......@@ -16,12 +19,9 @@
#include <boost/version.hpp>
#include <boost/format.hpp>
#ifdef NO_IMPORT_ARRAY
#undef NO_IMPORT_ARRAY
#endif
#include <bob.blitz/capi.h>
#include <bob.blitz/cleanup.h>
#include <bob.core/config.h>
#include <bob.io.base/config.h>
#include <bob.math/config.h>
#include <bob.learn.activation/config.h>
#include <bob.learn.linear/config.h>
......@@ -83,13 +83,6 @@ static PyObject* python_version() {
return Py_BuildValue("s", f.str().c_str());
}
/**
* Bob version, API version and platform
*/
static PyObject* bob_version() {
return Py_BuildValue("sis", BOB_VERSION, BOB_API_VERSION, BOB_PLATFORM);
}
/**
* Numpy version
*/
......@@ -105,6 +98,13 @@ static PyObject* bob_blitz_version() {
return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(BOB_BLITZ_API_VERSION));
}
/**
* bob.core c/c++ api version
*/
static PyObject* bob_core_version() {
return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(BOB_CORE_API_VERSION));
}
/**
* bob.io.base c/c++ api version
*/
......@@ -112,6 +112,14 @@ static PyObject* bob_io_base_version() {
return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(BOB_IO_BASE_API_VERSION));
}
/**
* bob.math c/c++ api version
*/
static PyObject* bob_math_version() {
return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(BOB_MATH_API_VERSION));
}
/**
* bob.io c/c++ api version
*/
......@@ -125,15 +133,17 @@ static PyObject* build_version_dictionary() {
if (!retval) return 0;
auto retval_ = make_safe(retval);
if (!dict_steal(retval, "Bob", bob_core_version())) return 0;
if (!dict_set(retval, "Blitz++", BZ_VERSION)) return 0;
if (!dict_steal(retval, "Boost", boost_version())) return 0;
if (!dict_steal(retval, "Compiler", compiler_version())) return 0;
if (!dict_steal(retval, "Python", python_version())) return 0;
if (!dict_steal(retval, "NumPy", numpy_version())) return 0;
if (!dict_steal(retval, "bob.blitz", bob_blitz_version())) return 0;
if (!dict_steal(retval, "bob.io", bob_io_base_version())) return 0;
if (!dict_steal(retval, "bob.core", bob_core_version())) return 0;
if (!dict_steal(retval, "bob.io.base", bob_io_base_version())) return 0;
if (!dict_steal(retval, "bob.math", bob_math_version())) return 0;
if (!dict_steal(retval, "bob.learn.activation", bob_learn_activation_version())) return 0;
if (!dict_steal(retval, "Bob", bob_version())) return 0;
Py_INCREF(retval);
return retval;
......
......@@ -10,7 +10,7 @@
#define BOB_LEARN_LINEAR_MODULE
#include <bob.blitz/cppapi.h>
#include <bob.blitz/cleanup.h>
#include <bob/config.h>
#include <bob.core/config.h>
#include <bob.learn.linear/api.h>
#include <structmember.h>
......
......@@ -10,7 +10,7 @@
#define BOB_LEARN_LINEAR_MODULE
#include <bob.blitz/cppapi.h>
#include <bob.blitz/cleanup.h>
#include <bob/config.h>
#include <bob.core/config.h>
#include <bob.learn.linear/api.h>
#include <structmember.h>
......
......@@ -10,20 +10,22 @@ extensions = bob.buildout
auto-checkout = *
develop = src/bob.extension
src/bob.blitz
src/bob.core
src/bob.io.base
src/bob.math
src/bob.learn.activation
.
; options for bob.buildout extension
debug = true
verbose = true
prefixes = /idiap/group/torch5spro/releases/preview/install/linux-x86_64-release
/Users/andre/work/bob/b/dbg/
[sources]
bob.extension = git https://github.com/bioidiap/bob.extension
bob.blitz = git https://github.com/bioidiap/bob.blitz
bob.core = git https://github.com/bioidiap/bob.core
bob.io.base = git https://github.com/bioidiap/bob.io.base
bob.math = git https://github.com/bioidiap/bob.math
bob.learn.activation = git https://github.com/bioidiap/bob.learn.activation
[scripts]
......
......@@ -3,23 +3,12 @@
# Andre Anjos <andre.anjos@idiap.ch>
# Mon 16 Apr 08:18:08 2012 CEST
bob_packages = ['bob.core', 'bob.math', 'bob.io.base', 'bob.learn.activation']
from setuptools import setup, find_packages, dist
dist.Distribution(dict(setup_requires=['bob.blitz', 'bob.io.base', 'bob.learn.activation']))
from bob.blitz.extension import Extension
import bob.io.base
import bob.learn.activation
import os
package_dir = os.path.dirname(os.path.realpath(__file__))
package_dir = os.path.join(package_dir, 'bob', 'learn', 'linear', 'include')
include_dirs = [
package_dir,
bob.blitz.get_include(),
bob.io.base.get_include(),
bob.learn.activation.get_include()
]
packages = ['bob-machine >= 2.0.0a2', 'bob-io >= 2.0.0a2']
dist.Distribution(dict(setup_requires=['bob.blitz'] + bob_packages))
from bob.blitz.extension import Extension, Library, build_ext
version = '2.0.0a0'
setup(
......@@ -41,24 +30,39 @@ setup(
install_requires=[
'setuptools',
'bob.blitz',
'bob.core',
'bob.io.base',
'bob.math',
'bob.learn.activation',
],
namespace_packages=[
"bob",
"bob.learn",
],
],
ext_modules = [
Extension("bob.learn.linear.version",
[
"bob/learn/linear/version.cpp",
],
packages = packages,
include_dirs = include_dirs,
],
bob_packages = bob_packages,
version = version,
),
Library("bob.learn.linear.bob_learn_linear",
[
"bob/learn/linear/cpp/machine.cpp",
"bob/learn/linear/cpp/pca.cpp",
"bob/learn/linear/cpp/lda.cpp",
"bob/learn/linear/cpp/logreg.cpp",
"bob/learn/linear/cpp/whitening.cpp",
"bob/learn/linear/cpp/wccn.cpp",
],
bob_packages = bob_packages,
version = version,
),
),
Extension("bob.learn.linear._library",
[
"bob/learn/linear/machine.cpp",
......@@ -68,23 +72,20 @@ setup(
"bob/learn/linear/whitening.cpp",
"bob/learn/linear/wccn.cpp",
"bob/learn/linear/main.cpp",
"bob/learn/linear/cpp/machine.cpp",
"bob/learn/linear/cpp/pca.cpp",
"bob/learn/linear/cpp/lda.cpp",
"bob/learn/linear/cpp/logreg.cpp",
"bob/learn/linear/cpp/whitening.cpp",
"bob/learn/linear/cpp/wccn.cpp",
],
packages = packages,
include_dirs = include_dirs,
bob_packages = bob_packages,
version = version,
),
],
),
],
cmdclass = {
'build_ext': build_ext
},
entry_points={
'console_scripts': [
],
},
],
},
classifiers = [
'Development Status :: 3 - Alpha',
......@@ -94,6 +95,6 @@ setup(
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries :: Python Modules',
],
],
)
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment