hikapok / tf.extra_losses Goto Github PK
View Code? Open in Web Editor NEWLarge-Margin Softmax Loss, Angular Softmax Loss, Additive Margin Softmax, ArcFaceLoss And FocalLoss In Tensorflow
License: MIT License
Large-Margin Softmax Loss, Angular Softmax Loss, Additive Margin Softmax, ArcFaceLoss And FocalLoss In Tensorflow
License: MIT License
Now, I try to install in virtual-env.
but I couldn't find the way for install.
could you help me?
In the "readme.md", there is "copy the header file "cuda\_config.h" from "your\_python\_path/site-packages/external/local\_config\_cuda/cuda/cuda/cuda\_config.h" to "your\_python\_path/site-packages/tensorflow/include/tensorflow/stream\_executor/cuda/cuda\_config.h".
But I can't find the path or "cuda_config.h" anywhere. It may lead to the failure of "make" command. Can you fix it?
When I run 'make' in build directory , there some errors:
[100%] Linking CXX shared library libextra_losses.so
/usr/bin/ld: 找不到 -ltensorflow_framework
collect2: error: ld returned 1 exit status
CMakeFiles/extra_losses.dir/build.make:166: recipe for target 'libextra_losses.so' failed
make[2]: *** [libextra_losses.so] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/extra_losses.dir/all' failed
make[1]: *** [CMakeFiles/extra_losses.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
do you know the reason? thank you for your help.
ubuntu16.04+python3.6(anaconda3)+tensorflow1.6
thank you very much.
Hi
I am using Keras api for model training and testing. May I know how to use the loss function in this project together with Keras api?
Thank you!
I have Ubuntu 16.04, Python 3.5.2 in a virtual env, and Tensorflow 1.6 GPU.
I have 2 1080ti.
I have run the "cd build && cmake .." and the output is:
`-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda-9.0 (found version "9.0")
-- Found CWD: /home/vision/matthew/tf.extra_losses/build
-- Found GPU_CAPABILITY: gencode arch=compute_61,code=sm_61/home/vision/tf_16/lib/python3.5/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype from
float
tonp.floating
is deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type
.
from ._conv import register_converters as _register_converters
/home/vision/tf_16/lib/python3.5/site-packages/h5py/init.py:36: FutureWarning: Conversion of the second argument of issubdtype fromfloat
tonp.floating
is deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type
.
from ._conv import register_converters as _register_converters
-- Found TF_INC: /home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include
-- Found TF_INC_EXTERNAL: /home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/external/nsync/public
-- Found TF_LIB: /home/vision/tf_16/lib/python3.5/site-packages/tensorflow
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vision/matthew/tf.extra_losses/build
`
And Also 'make' command:
`[ 16%] Building NVCC (Device) object CMakeFiles/cuda_compile.dir/cuda_compile_generated_l_softmax_grad_op.cu.o
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cu:181:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cu:181:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cu:181:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(57): warning: integer conversion resulted in a change of sign/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(304): warning: integer conversion resulted in a change of sign
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(305): warning: integer conversion resulted in a change of sign
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cu:181:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(57): warning: integer conversion resulted in a change of sign/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(304): warning: integer conversion resulted in a change of sign
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(305): warning: integer conversion resulted in a change of sign
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/generated_message_reflection.h(685): warning: variable "unused" was set but never used
[ 33%] Building NVCC (Device) object CMakeFiles/cuda_compile.dir/cuda_compile_generated_l_softmax_op.cu.o
/home/vision/matthew/tf.extra_losses/l_softmax_op.cu:131:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_op.cu:131:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_op.cu:131:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(57): warning: integer conversion resulted in a change of sign/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(304): warning: integer conversion resulted in a change of sign
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(305): warning: integer conversion resulted in a change of sign
/home/vision/matthew/tf.extra_losses/common.h(32): warning: the "always_inline" attribute is ignored on non-inline functions
/home/vision/matthew/tf.extra_losses/common.h(46): warning: the "always_inline" attribute is ignored on non-inline functions
/home/vision/matthew/tf.extra_losses/common.h(52): warning: the "always_inline" attribute is ignored on non-inline functions
/home/vision/matthew/tf.extra_losses/l_softmax_op.cu:131:1: warning: multi-line comment [-Wcomment]
// #define DEFINE_GPU_SPECS(T)
^
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(57): warning: integer conversion resulted in a change of sign/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(304): warning: integer conversion resulted in a change of sign
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/arena_impl.h(305): warning: integer conversion resulted in a change of sign
/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/include/google/protobuf/generated_message_reflection.h(685): warning: variable "unused" was set but never used
/home/vision/matthew/tf.extra_losses/common.h(32): warning: the "always_inline" attribute is ignored on non-inline functions
/home/vision/matthew/tf.extra_losses/common.h(46): warning: the "always_inline" attribute is ignored on non-inline functions
/home/vision/matthew/tf.extra_losses/common.h(52): warning: the "always_inline" attribute is ignored on non-inline functions
Scanning dependencies of target extra_losses
[ 50%] Building CXX object CMakeFiles/extra_losses.dir/l_softmax_op.cc.o
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc:274:0: warning: "REGISTER_CPU" redefined
#define REGISTER_CPU(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc:268:0: note: this is the location of the previous definition
#define REGISTER_CPU(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc:291:0: warning: "REGISTER_GPU" redefined
#define REGISTER_GPU(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc:285:0: note: this is the location of the previous definition
#define REGISTER_GPU(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc: In lambda function:
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc:62:40: warning: variable ‘num_dimensions’ set but not used [-Wunused-but-set-variable]
shape_inference::DimensionHandle num_dimensions = c->Dim(features_shape, 1);
^
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc: In lambda function:
/home/vision/matthew/tf.extra_losses/l_softmax_op.cc:93:40: warning: variable ‘num_dimensions’ set but not used [-Wunused-but-set-variable]
shape_inference::DimensionHandle num_dimensions = c->Dim(features_shape, 1);
^
[ 66%] Building CXX object CMakeFiles/extra_losses.dir/l_softmax_grad_op.cc.o
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cc:293:0: warning: "REGISTER_CPU" redefined
#define REGISTER_CPU(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cc:287:0: note: this is the location of the previous definition
#define REGISTER_CPU(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cc:310:0: warning: "REGISTER_GPU" redefined
#define REGISTER_GPU(T)
^
/home/vision/matthew/tf.extra_losses/l_softmax_grad_op.cc:304:0: note: this is the location of the previous definition
#define REGISTER_GPU(T)
^
[ 83%] Building CXX object CMakeFiles/extra_losses.dir/common.cc.o
In file included from /home/vision/matthew/tf.extra_losses/common.cc:22:0:
/home/vision/matthew/tf.extra_losses/common.h:46:37: warning: always_inline function might not be inlinable [-Wattributes]
attribute((always_inline)) bool is_pow2(const T x)
^
/home/vision/matthew/tf.extra_losses/common.h:32:39: warning: always_inline function might not be inlinable [-Wattributes]
attribute((always_inline)) Target binary_cast(Source s)
^
/home/vision/matthew/tf.extra_losses/common.h:32:39: warning: always_inline function might not be inlinable [-Wattributes]
/home/vision/matthew/tf.extra_losses/common.h:52:37: warning: always_inline function might not be inlinable [-Wattributes]
attribute((always_inline)) bool is_aligned(const T ptr, const size_t alignment)
^
[100%] Linking CXX shared library libextra_losses.so
[100%] Built target extra_losses
`
but unfortunately got an error in test_op.py execution:
/home/vision/tf_16/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from
floatto
np.floatingis deprecated. In future, it will be treated as
np.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Traceback (most recent call last): File "test_op.py", line 36, in <module> op_module = load_op_module(LIB_NAME) File "test_op.py", line 33, in load_op_module oplib = tf.load_op_library(lib_path) File "/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/python/framework/load_library.py", line 58, in load_op_library lib_handle = py_tf.TF_LoadLibrary(library_filename, status) File "/home/vision/tf_16/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__ c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: /home/vision/matthew/tf.extra_losses/build/libextra_losses.so: undefined symbol: _ZNK10tensorflow8OpKernel11type_stringEv
What should do?!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.