- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
const range = (count) => Array.from(Array(count).keys());
class Matrix {
static Dot(A, B) {
// Dot production
const wA = A[0].length;
const hA = A.length;
const wB = B[0].length;
const hB = B.length;
if (wA != hB)
{
throw "A width != B height";
}
const C = range(hA).map((_, i) => range(wB).map((_, j) => 0));
for (let i = 0; i < hA; ++i)
for (let j = 0; j < wB; ++j) {
let sum = 0;
for (let k = 0; k < wA; ++k) {
const a = A[i][k];
const b = B[k][j];
sum += a * b;
}
C[i][j] = sum;
}
return C;
}
static Mul(A, B) {
// Dot production
const wA = A[0].length;
const hA = A.length;
const wB = B[0].length;
const hB = B.length;
if (wA != wB || hA != hB)
{
throw "A width != B width, A height != B height";
}
const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] * B[i][j]));
return C;
}
static Add(A, B) {
const wA = A[0].length;
const hA = A.length;
const wB = B[0].length;
const hB = B.length;
if (wA != wB || hA != hB)
{
throw "A width != B width, A height != B height";
}
const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + B[i][j]));
return C;
}
static Sub(A, B) {
const wA = A[0].length;
const hA = A.length;
const wB = B[0].length;
const hB = B.length;
if (wA != wB || hA != hB)
{
throw "A width != B width, A height != B height";
}
const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] - B[i][j]));
return C;
}
static Translate(A, shift) {
const wA = A[0].length;
const hA = A.length;
const R = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + shift));
return R;
}
static Sigmoid(A) {
const wA = A[0].length;
const hA = A.length;
const R = range(hA).map((_, i) => range(wA).map((_, j) => 1 / (1 + Math.exp(-A[i][j]))));
return R;
}
//...
}
JloJle4Ka 26.09.2021 06:07 # 0
JloJle4Ka 26.09.2021 06:08 # 0
Ого!
JloJle4Ka 26.09.2021 06:09 # 0
> return R;
Это искусство -- писать лабу...
ASD_77 26.09.2021 13:11 # +1
CBuHOKYP 26.09.2021 23:24 # 0
guest6 26.09.2021 13:16 # 0
ASD_77 26.09.2021 13:19 # +1
guest6 26.09.2021 13:20 # 0
ASD_77 26.09.2021 13:41 # 0
JloJle4Ka 26.09.2021 13:42 # 0
guest6 26.09.2021 15:22 # 0
ASD_77 26.09.2021 15:41 # 0
guest6 26.09.2021 15:44 # 0
10 PRINT "Hello"
вот это всё
6E3BY3HuK 26.09.2021 22:44 # 0
CBuHOKYP 26.09.2021 23:04 # 0
CBuHOKYP 26.09.2021 23:15 # 0
ASD_77 27.09.2021 01:58 # +1
guest6 27.09.2021 02:19 # 0
CBuHOKYP 26.09.2021 23:15 # 0
except
// вонь
end;
CBuHOKYP 27.09.2021 12:02 # 0