Skip to content

Commit ef3f234

Browse files
committed
wipe out compiler warinngs (Visual Studio /W4)
1 parent 3b8f773 commit ef3f234

File tree

8 files changed

+12
-9
lines changed

8 files changed

+12
-9
lines changed

include/activation_function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class activation {
4040
class identity_activation : public activation {
4141
public:
4242
float_t f(float_t x) const { return x; }
43-
float_t df(float_t f_x) const { return 1; }
43+
float_t df(float_t /*f_x*/) const { return 1; }
4444
std::pair<float_t, float_t> scale() const { return std::make_pair(0.1, 0.9); }
4545
};
4646

include/image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class image {
7979

8080
// color palette (256*3byte)
8181
for (int i = 0; i < 256; i++) {
82-
const char v = i;
82+
const char v = static_cast<const char>(i);
8383
ofs.write(&v, 1);//R
8484
ofs.write(&v, 1);//G
8585
ofs.write(&v, 1);//B

include/layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class input_layer : public layer<N, identity_activation> {
225225
return this->next_ ? this->next_->forward_propagation(in, index) : this->output_[index];
226226
}
227227

228-
const vec_t& back_propagation(const vec_t& current_delta, int index) {
228+
const vec_t& back_propagation(const vec_t& current_delta, int /*index*/) {
229229
return current_delta;
230230
}
231231

include/network.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ class network {
283283

284284
template<typename Activation, typename Loss>
285285
bool is_canonical_link(const Activation& h, const Loss& E) {
286+
CNN_UNREFERENCED_PARAMETER(E);
286287
if (typeid(h) == typeid(sigmoid_activation) && typeid(E) == typeid(cross_entropy)) return true;
287288
if (typeid(h) == typeid(tanh_activation) && typeid(E) == typeid(cross_entropy)) return true;
288289
if (typeid(h) == typeid(identity_activation) && typeid(E) == typeid(mse)) return true;

include/optimizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct optimizer {
3737
struct gradient_descent_levenberg_marquardt : public optimizer {
3838
public:
3939
gradient_descent_levenberg_marquardt() : alpha(0.00085), mu(0.02) {}
40-
gradient_descent_levenberg_marquardt(float_t alpha, float_t lambda, float_t mu) : alpha(alpha), mu(mu) {}
40+
gradient_descent_levenberg_marquardt(float_t alpha, float_t mu) : alpha(alpha), mu(mu) {}
4141

4242
void update(float_t dW, float_t H, float_t *W) {
4343
*W -= (alpha / (H + mu)) * (dW); // 7.2%
@@ -55,7 +55,7 @@ struct gradient_descent : public optimizer {
5555
gradient_descent() : alpha(0.01), lambda(0.0) {}
5656
gradient_descent(float_t alpha, float_t lambda) : alpha(alpha), lambda(lambda) {}
5757

58-
void update(float_t dW, float_t H, float_t *W) {
58+
void update(float_t dW, float_t /*H*/, float_t *W) {
5959
*W -= alpha * ((dW) + *W * lambda); // 7.2%
6060
}
6161

include/partial_connected_layer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,13 @@ class partial_connected_layer : public layer<N, Activation> {
188188
for (int i = 0; i < this->out_size_; i++) {
189189
wi_connections& wi = out2wi_[i];
190190
for (size_t j = 0; j < wi.size(); j++)
191-
wi[j].first = swaps[wi[j].first];
191+
wi[j].first = static_cast<unsigned short>(swaps[wi[j].first]);
192192
}
193193

194194
for (int i = 0; i < this->in_size_; i++) {
195195
wo_connections& wo = in2wo_[i];
196196
for (size_t j = 0; j < wo.size(); j++)
197-
wo[j].first = swaps[wo[j].first];
197+
wo[j].first = static_cast<unsigned short>(swaps[wo[j].first]);
198198
}
199199

200200
std::vector<io_connections> weight2io_new(n);

include/product.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace detail {
4545

4646

4747
template<typename T>
48-
inline bool is_aligned(T, const typename T::value_type* p) {
48+
inline bool is_aligned(T, const typename T::value_type* /*p*/) {
4949
return true;
5050
}
5151

include/util.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#endif
3939
#include "fixed_point.h"
4040

41+
#define CNN_UNREFERENCED_PARAMETER(x) (void)(x)
42+
4143
namespace tiny_cnn {
4244

4345
typedef double float_t;
@@ -168,7 +170,7 @@ void parallel_for(int begin, int end, const Func& f) {
168170
}
169171

170172
template<typename Func>
171-
void for_(bool parallelize, int begin, int end, Func f) {
173+
void for_(bool /*parallelize*/, int begin, int end, Func f) { // ignore parallelize if you don't define CNN_USE_TBB
172174
parallel_for(begin, end, f);
173175
}
174176

0 commit comments

Comments
 (0)