Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] ResNet #21

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix build
  • Loading branch information
lgarithm committed Apr 7, 2019
commit 94077e6a7b64802467bcfafbf814913d4c8dcb21
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ IncludeCategories:
Priority: 1
# standard C++ headers
# TODO: add as needed
- Regex: ^<(algorithm|array|condition_variable|functional|iostream|map|memory|mutex|numeric|string|thread|type_traits|vector)>$
- Regex: ^<(algorithm|array|condition_variable|functional|iomanip|iostream|map|memory|mutex|numeric|string|thread|type_traits|vector)>$
Priority: 2
# third party headers
- Regex: ^<stdtensor>
Expand Down
20 changes: 12 additions & 8 deletions examples/example_model_plain50.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@ class plain50_model
using bn_layer = nn::layers::batch_norm<image_order, relu>;

using flatten = nn::layers::flatten<1, 3>;
using conv = nn::layers::conv<image_order, filter_order, false>;
using conv = nn::layers::conv<image_order, filter_order, true>;
using softmax = nn::layers::activation<nn::ops::softmax>;

auto conv7x7(int d) const
{
using conv_relu =
nn::layers::conv<image_order, filter_order, false, relu>;

nn::layers::conv<image_order, filter_order, true, relu>;
return with_init(conv_relu(d, conv_relu::ksize(7, 7),
conv_relu::padding_same(),
conv_relu::stride(2, 2)),
show_name("w"));
show_name("conv1/kernel"), show_name("conv1/bias"));
}

auto bn() const
{
return with_init(bn_layer(), //
show_name("mean"), show_name("var"), show_name("beta"),
show_name("gamma"));
// show_name("mean"), show_name("var"),
nn::ops::noop(), //
nn::ops::noop(), //
show_name("bn_conv?/beta"),
show_name("bn_conv?/gamma"));
}

auto pool1() const
Expand All @@ -58,14 +60,16 @@ class plain50_model
{
return with_init(conv(d, conv::ksize(1, 1), conv::padding_same(),
conv::stride(s, s)),
show_name("W"));
show_name("res??_branch??/kernel"),
show_name("res??_branch??/bias"));
}

auto conv3x3(int d, int s) const
{
return with_init(conv(d, conv::ksize(3, 3), conv::padding_same(),
conv::stride(s, s)),
show_name("W"));
show_name("res??_branch??/kernel"),
show_name("res??_branch??/bias"));
}

// auto conv2_x() const {}
Expand Down
5 changes: 4 additions & 1 deletion examples/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <iomanip>
#include <iostream>
#include <string>

#include <stdtensor>
Expand Down Expand Up @@ -50,7 +52,8 @@ class show_name
template <typename R, ttl::rank_t r>
void operator()(const ttl::tensor_ref<R, r> &y) const
{
std::cerr << name_ << " :: " << std::endl;
std::cerr << std::left << std::setw(32) << name_
<< " :: " << show_shape(y.shape()) << std::endl;
}
};
} // namespace nn::layers::debug