- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtensorarray.java
More file actions
Latest commit
74 lines (69 loc) · 1.23 KB
/
Copy pathtensorarray.java
File metadata and controls
74 lines (69 loc) · 1.23 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
packagetensordef;
importjava.util.*;
importjava.util.Random;
importbasicops.*;
importjava.math.*;
publicclasstensorarray
{
publictensorarr[][];
publicintdim1, dim2;
publicbooleantrainable;
publictensorarray(intdim1,intdim2,booleantrainable)
{
arr=newtensor[dim1][dim2];
this.dim1=dim1;
this.dim2=dim2;
this.trainable=trainable;
randomintialize();
}
publicvoidrandomintialize()
{
Randomrand = newRandom();
for (inti=0;i<dim1;i++)
{
for (intj=0;j<dim2;j++)
{
if(rand.nextDouble()<0.5)
arr[i][j]=newtensor(rand.nextDouble(),trainable);
else
arr[i][j]=newtensor(-rand.nextDouble(),trainable);
//System.out.println(arr[i][j].data);
}
}
}
publicvoidones()
{
for (inti=0;i<dim1;i++)
{
for (intj=0;j<dim2;j++)
{
arr[i][j].data=1;
//System.out.println(arr[i][j].data);
}
}
}
publicvoidassign(doublecustomdata[][])
{
for(inti=0;i<dim1;i++)
{
for(intj=0;j<dim2;j++)
{
arr[i][j].data=customdata[i][j];
}
}
}
publicvoidassigntensorarray(tensorarrayt)
{
for(inti=0;i<dim1;i++)
{
for(intj=0;j<dim2;j++)
{
arr[i][j].data=t.arr[i][j].data;
}
}
}
publicvoidassign(tensorip)
{
arr[0][0]=ip;
}
}