- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtensorarray3d.java
More file actions
Latest commit
104 lines (101 loc) · 1.72 KB
/
Copy pathtensorarray3d.java
File metadata and controls
104 lines (101 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
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
97
98
99
100
101
102
103
104
packagetensordef;
importbasicops.*;
importjava.util.Random;
publicclasstensorarray3d
{
publictensorarr[][][];
publicintdim1;
publicintdim2;
publicintdim3;
booleantrainable;
publictensorarray3d(intdim1,intdim2,intdim3,booleantrainable)
{
this.dim1=dim1;
this.dim2=dim2;
this.dim3=dim3;
this.trainable=trainable;
arr=newtensor[dim1][dim2][dim3];
randominitialize();
}
publicvoidrandominitialize()
{
Randomrand = newRandom();
for (inti=0;i<dim1;i++)
{
for (intj=0;j<dim2;j++)
{
for(intk=0;k<dim3;k++)
{
arr[i][j][k]=newtensor(rand.nextDouble(),trainable);
//System.out.println(arr[i][j].data);
}
}
}
}
publicvoidones()
{
for (inti=0;i<dim1;i++)
{
for (intj=0;j<dim2;j++)
{
for(intk=0;k<dim3;k++)
arr[i][j][k].data=1;
//System.out.println(arr[i][j].data);
}
}
}
publicvoidprint()
{
for(inti=0;i<dim1;i++)
{
for(intj=0;j<dim2;j++)
{
for(intk=0;k<dim3;k++)
{
System.out.println(arr[i][j][k].data);
}
}
}
System.out.println("------------");
}
publicvoidzeros()
{
for(inti=0;i<dim1;i++)
{
for(intj=0;j<dim2;j++)
{
for(intk=0;k<dim3;k++)
{
arr[i][j][k].data=0;
}
}
}
}
publicvoidassign(doublecustomdata[][][])
{
for(inti=0;i<dim1;i++)
{
for(intj=0;j<dim2;j++)
{
for(intk=0;k<dim3;k++)
arr[i][j][k].data=customdata[i][j][k];
}
}
}
publicvoidassigntensorarray(tensorarray3dt)
{
for(inti=0;i<dim1;i++)
{
for(intj=0;j<dim2;j++)
{
for(intk=0;k<dim3;k++)
arr[i][j][k].data=t.arr[i][j][k].data;
}
}
}
publicvoidassigntensor(tensort,inti,intj,intk)
{
arr[i][j][k]=null;
arr[i][j][k]=t;
}
}