Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3e9b9f1
Implementation of linear_ layer for neural networks. This layer provi…
Cydral Apr 28, 2025
93ead3d
Minor change
Cydral May 2, 2025
bf1b805
Update dlib/dnn/layers.h
davisking May 3, 2025
49bfbc6
Merge branch 'davisking:master' into master
Cydral May 6, 2025
f234faa
Add reshape_to and flatten layers to Dlib's DNN module
Cydral May 6, 2025
26a2960
Missing update to "visitors.h"
Cydral May 22, 2025
c9a1ee4
format fixing for reshape_to
Cydral May 22, 2025
02e62d8
Update dlib/test/dnn.cpp
davisking May 23, 2025
394dee8
Merge branch 'davisking:master' into master
Cydral May 29, 2025
778bfc1
Vocabulary size fixed for learning, and function added for transforma…
Cydral May 29, 2025
03aafc2
Added a new example for learning a “complex” Transformer model.
Cydral May 29, 2025
22c2561
Added a new example for learning a “complex” Transformer model.
Cydral May 29, 2025
01cd0b2
Updated example for training a Transformer model.
Cydral May 29, 2025
6b63e55
fix for gcc/ffmpeg compilation
Cydral May 30, 2025
ad1f757
Fix a warning message for Ubuntu compilation.
Cydral May 30, 2025
c91c45a
Update for Linux environment.
Cydral May 30, 2025
6fcc0aa
Fix batch building
Cydral May 31, 2025
5a1773e
Slight improvement in model definition.
Cydral Jun 3, 2025
10d7c59
linear_ layer implementation improvement
Cydral Jun 7, 2025
d4bf94b
finalizing the example
Cydral Jun 7, 2025
a4dac0b
Fixing break condition in training method.
Cydral Jun 8, 2025
63454e3
Fixing declaration order of variables.
Cydral Jun 8, 2025
87ed70a
bpe_tokenizer improvements.
Cydral Jun 8, 2025
061c673
Example updated.
Cydral Jun 16, 2025
f6c8526
bpe_tokenizer class refactoring.
Cydral Jun 16, 2025
2db56f5
Example updated.
Cydral Jun 16, 2025
d4eeb2d
bpe_tokenizer class updated.
Cydral Jun 16, 2025
dcb5963
Decoding part of the bpe_tokenizer updated.
Cydral Jun 17, 2025
b81b502
Network definition update
Cydral Jun 27, 2025
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
37 changes: 30 additions & 7 deletions dlib/dnn/layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2329,24 +2329,46 @@ namespace dlib

template <
unsigned long num_outputs_,
linear_bias_mode bias_mode_
linear_bias_mode bias_mode_ = LINEAR_HAS_BIAS
>
class linear_
{
static_assert(num_outputs_ > 0, "The number of outputs from a linear_ layer must be > 0");

public:
linear_() :
explicit linear_() :
num_outputs(num_outputs_),
num_inputs(0),
num_inputs(0),
learning_rate_multiplier(1),
bias_mode(bias_mode_) {
}

linear_(const linear_& other) :
num_outputs(other.num_outputs),
num_inputs(other.num_inputs),
learning_rate_multiplier(other.learning_rate_multiplier),
bias_mode(other.bias_mode),
params(other.params),
weights(other.weights),
biases(other.biases) {
}

linear_& operator=(const linear_& other) {
if (this != &other) {
num_outputs = other.num_outputs;
num_inputs = other.num_inputs;
learning_rate_multiplier = other.learning_rate_multiplier;
bias_mode = other.bias_mode;
params = other.params;
weights = other.weights;
biases = other.biases;
}
return *this;
}

double get_learning_rate_multiplier() const { return learning_rate_multiplier; }
void set_learning_rate_multiplier(double val) { learning_rate_multiplier = val; }

unsigned long get_num_inputs() const { return num_inputs; }

unsigned long get_num_outputs() const { return num_outputs; }
void set_num_outputs(long num)
{
Expand All @@ -2358,6 +2380,7 @@ namespace dlib
num_outputs = num;
}
}
unsigned long get_num_inputs() const { return num_inputs; }
linear_bias_mode get_bias_mode() const { return bias_mode; }

template <typename SUBNET>
Expand Down Expand Up @@ -2503,8 +2526,8 @@ namespace dlib
}

private:
unsigned long num_inputs;
unsigned long num_outputs;
unsigned long num_inputs;
double learning_rate_multiplier;
linear_bias_mode bias_mode;
resizable_tensor params;
Expand All @@ -2515,7 +2538,7 @@ namespace dlib
unsigned long num_outputs,
typename SUBNET
>
using linear = add_layer<linear_<num_outputs, LINEAR_HAS_BIAS>, SUBNET>;
using linear = add_layer<linear_<num_outputs>, SUBNET>;

template <
unsigned long num_outputs,
Expand Down
Loading
Loading