silly boi
parent
1febcb48b3
commit
dd313d75dd
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(COSC-4P80-Assignment-2 VERSION 0.0.6)
|
||||
project(COSC-4P80-Assignment-2 VERSION 0.0.7)
|
||||
|
||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||
|
|
|
@ -102,10 +102,15 @@ namespace assign2
|
|||
class weight_t
|
||||
{
|
||||
public:
|
||||
void preallocate(blt::size_t amount)
|
||||
{
|
||||
data.resize(amount);
|
||||
}
|
||||
|
||||
weight_view allocate_view(blt::size_t count)
|
||||
{
|
||||
auto size = data.size();
|
||||
data.resize(size + count);
|
||||
auto size = place;
|
||||
place += count;
|
||||
return {&data[size], count};
|
||||
}
|
||||
|
||||
|
@ -116,6 +121,7 @@ namespace assign2
|
|||
}
|
||||
|
||||
private:
|
||||
blt::size_t place = 0;
|
||||
std::vector<Scalar> data;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "blt/std/assert.h"
|
||||
#ifndef COSC_4P80_ASSIGNMENT_2_LAYER_H
|
||||
#define COSC_4P80_ASSIGNMENT_2_LAYER_H
|
||||
|
||||
|
@ -51,6 +52,7 @@ namespace assign2
|
|||
{
|
||||
// delta for weights
|
||||
error = act->derivative(z) * next_error;
|
||||
BLT_ASSERT(previous_outputs.size() == dw.size());
|
||||
for (auto [prev_out, d_weight] : blt::zip(previous_outputs, dw))
|
||||
{
|
||||
// dw / apply dw
|
||||
|
@ -103,6 +105,8 @@ namespace assign2
|
|||
in_size(in), out_size(out), act_func(act_func)
|
||||
{
|
||||
neurons.reserve(out_size);
|
||||
weights.preallocate(in_size * out_size);
|
||||
weight_derivatives.preallocate(in_size * out_size);
|
||||
for (blt::i32 i = 0; i < out_size; i++)
|
||||
{
|
||||
auto weight = weights.allocate_view(in_size);
|
||||
|
|
Loading…
Reference in New Issue