-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7fb343
commit 23aa1e1
Showing
13 changed files
with
2,508 additions
and
2,569 deletions.
There are no files selected for viewing
1,201 changes: 1,201 additions & 0 deletions
1,201
attention_mechanism/.ipynb_checkpoints/Attention_Mechanism-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
799 changes: 0 additions & 799 deletions
799
attention_mechanism/.ipynb_checkpoints/Bahdanau Attention Mechanism-checkpoint.ipynb
This file was deleted.
Oops, something went wrong.
456 changes: 0 additions & 456 deletions
456
attention_mechanism/.ipynb_checkpoints/Luong Attention Mechanism-checkpoint.ipynb
This file was deleted.
Oops, something went wrong.
2,343 changes: 1,169 additions & 1,174 deletions
2,343
attention_mechanism/Attention_Mechanism.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// Created by Tran Giang on 7/25/22. | ||
// | ||
#include "vector.h" | ||
#include <iostream> | ||
|
||
int main(){ | ||
Vector<int> v (5); | ||
std::cout << v; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// | ||
// Created by Tran Giang on 7/25/22. | ||
// | ||
#include "matrix.h" | ||
|
||
template<typename T> | ||
Matrix<T>::Matrix(int rows, int columns):rows(rows), columns(columns) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Created by Tran Giang on 7/25/22. | ||
// | ||
|
||
#ifndef ML_FROM_SCRATCH_MATRIX_H | ||
#define ML_FROM_SCRATCH_MATRIX_H | ||
|
||
template<typename T> | ||
class Matrix{ | ||
private: | ||
int rows; | ||
int columns; | ||
T* elements; | ||
public: | ||
Matrix(int rows, int columns); | ||
}; | ||
|
||
#endif //ML_FROM_SCRATCH_MATRIX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "vector.h" | ||
#include <stdlib.h> | ||
|
||
template<typename T> | ||
Vector<T>::Vector(int size): size(size) { | ||
elements = new T[size]; | ||
for (int i = 0; i < size; ++i) { | ||
elements[i] = rand(); | ||
} | ||
} | ||
|
||
template<typename T> | ||
Vector<T>::~Vector() { | ||
delete elements; | ||
elements = nullptr; | ||
} | ||
|
||
template<typename T> | ||
T Vector<T>::dot(Vector<T> &other) { | ||
T result; | ||
for (int i = 0; i < other.size; i++) { | ||
result += elements[i] + other.elements[i]; | ||
} | ||
return result; | ||
} | ||
|
||
template<typename T> | ||
const T &Vector<T>::operator[](int i) const { | ||
return elements[i]; | ||
} | ||
|
||
template<typename T> | ||
template<typename Scalar> | ||
Vector<T> &Vector<T>::operator+(const Scalar &i) { | ||
for (T& element: elements) { | ||
element = element + i; | ||
} | ||
return *this; | ||
} | ||
|
||
template<typename T> | ||
template<typename Scalar> | ||
Vector<T> &Vector<T>::operator-(const Scalar &i) { | ||
return *this; | ||
} | ||
|
||
template<typename T> | ||
template<typename Scalar> | ||
Vector<T> &Vector<T>::operator*(const Scalar &i) { | ||
return *this; | ||
} | ||
|
||
template<typename T> | ||
template<typename Scalar> | ||
Vector<T> &Vector<T>::operator/(const Scalar &i) { | ||
return *this; | ||
} | ||
|
||
template<typename T> | ||
std::ostream &Vector<T>::operator<<(std::ostream &outs) { | ||
for (auto elem: elements) { | ||
outs << elem << std::endl; | ||
} | ||
return outs; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <iostream> | ||
|
||
template<typename T> | ||
class Vector | ||
{ | ||
private: | ||
int size; | ||
T* elements; | ||
public: | ||
Vector(int size); | ||
|
||
~Vector(); | ||
|
||
T dot(Vector<T>& other); | ||
|
||
const T& operator[](int i) const; | ||
|
||
template<typename Scalar> | ||
Vector<T>& operator+(const Scalar& i); | ||
|
||
template<typename Scalar> | ||
Vector<T>& operator-(const Scalar& i); | ||
|
||
template<typename Scalar> | ||
Vector<T>& operator*(const Scalar& i); | ||
|
||
template<typename Scalar> | ||
Vector<T>& operator/(const Scalar& i); | ||
|
||
std::ostream& operator<<(std::ostream& outs); | ||
}; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters