@webwriter/deep-learning-model 0.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.github/workflows/main.yml +8 -0
  2. package/LICENSE +7 -0
  3. package/README.md +290 -0
  4. package/components/dataset-input/dataset-input.styles.ts +20 -0
  5. package/components/dataset-input/dataset-input.ts +196 -0
  6. package/components/inference-fields/class-input.ts +83 -0
  7. package/components/inference-fields/class-output.ts +62 -0
  8. package/components/inference-fields/image-input.ts +182 -0
  9. package/components/inference-fields/image.ts +82 -0
  10. package/components/inference-fields/inference-interfaces.ts +15 -0
  11. package/components/inference-fields/number-input.ts +62 -0
  12. package/components/inference-fields/number-output.ts +56 -0
  13. package/components/model-editor.ts +288 -0
  14. package/components/model-tests/bad-samples.ts +152 -0
  15. package/components/model-tests/loss-distribution.ts +174 -0
  16. package/components/reference-element-select.ts +105 -0
  17. package/custom-elements.json +1470 -0
  18. package/custom.d.ts +180 -0
  19. package/dist/widgets/webwriter-feature-engineering.css +444 -0
  20. package/dist/widgets/webwriter-feature-engineering.js +112763 -0
  21. package/dist/widgets/webwriter-model-designing.css +444 -0
  22. package/dist/widgets/webwriter-model-designing.js +114587 -0
  23. package/dist/widgets/webwriter-model-evaluation.css +444 -0
  24. package/dist/widgets/webwriter-model-evaluation.js +119010 -0
  25. package/dist/widgets/webwriter-model-prediction.css +444 -0
  26. package/dist/widgets/webwriter-model-prediction.js +109251 -0
  27. package/dist/widgets/webwriter-model-training.css +444 -0
  28. package/dist/widgets/webwriter-model-training.js +121465 -0
  29. package/editing-config.json +73 -0
  30. package/icon.svg +1 -0
  31. package/lib/dataset/class.ts +155 -0
  32. package/lib/dataset/dataset.ts +293 -0
  33. package/lib/dataset/feature.ts +110 -0
  34. package/lib/dataset/image.ts +312 -0
  35. package/lib/dataset/linear.ts +120 -0
  36. package/lib/layers/activation.ts +48 -0
  37. package/lib/layers/add.ts +50 -0
  38. package/lib/layers/attention.ts +74 -0
  39. package/lib/layers/concat.ts +50 -0
  40. package/lib/layers/conv.ts +83 -0
  41. package/lib/layers/dropout.ts +44 -0
  42. package/lib/layers/fcl.ts +66 -0
  43. package/lib/layers/flatten.ts +48 -0
  44. package/lib/layers/index.ts +770 -0
  45. package/lib/layers/input.ts +55 -0
  46. package/lib/layers/noise.ts +43 -0
  47. package/lib/layers/output.ts +64 -0
  48. package/lib/layers/reshape.ts +76 -0
  49. package/lib/layers/transposeconv.ts +90 -0
  50. package/lib/tflib.ts +10 -0
  51. package/lit-localize.json +47 -0
  52. package/localization/ar.xlf +553 -0
  53. package/localization/bg.xlf +552 -0
  54. package/localization/cs.xlf +553 -0
  55. package/localization/da.xlf +552 -0
  56. package/localization/de.xlf +552 -0
  57. package/localization/el.xlf +554 -0
  58. package/localization/es.xlf +553 -0
  59. package/localization/et.xlf +553 -0
  60. package/localization/fi.xlf +552 -0
  61. package/localization/fr.xlf +553 -0
  62. package/localization/generated/ar.ts +159 -0
  63. package/localization/generated/bg.ts +158 -0
  64. package/localization/generated/cs.ts +159 -0
  65. package/localization/generated/da.ts +158 -0
  66. package/localization/generated/de.ts +158 -0
  67. package/localization/generated/el.ts +160 -0
  68. package/localization/generated/es.ts +159 -0
  69. package/localization/generated/et.ts +159 -0
  70. package/localization/generated/fi.ts +158 -0
  71. package/localization/generated/fr.ts +159 -0
  72. package/localization/generated/hu.ts +158 -0
  73. package/localization/generated/id.ts +159 -0
  74. package/localization/generated/index.js +3 -0
  75. package/localization/generated/it.ts +159 -0
  76. package/localization/generated/ja.ts +158 -0
  77. package/localization/generated/ko.ts +158 -0
  78. package/localization/generated/locale-codes.js +83 -0
  79. package/localization/generated/lt.ts +158 -0
  80. package/localization/generated/lv.ts +158 -0
  81. package/localization/generated/nb.ts +158 -0
  82. package/localization/generated/nl.ts +158 -0
  83. package/localization/generated/pl.ts +159 -0
  84. package/localization/generated/pt-BR.ts +159 -0
  85. package/localization/generated/pt-PT.ts +159 -0
  86. package/localization/generated/ro.ts +159 -0
  87. package/localization/generated/ru.ts +159 -0
  88. package/localization/generated/sk.ts +159 -0
  89. package/localization/generated/sl.ts +159 -0
  90. package/localization/generated/sv.ts +158 -0
  91. package/localization/generated/tr.ts +158 -0
  92. package/localization/generated/uk.ts +158 -0
  93. package/localization/generated/zh-hans.ts +141 -0
  94. package/localization/generated/zh-hant.ts +141 -0
  95. package/localization/hu.xlf +552 -0
  96. package/localization/id.xlf +553 -0
  97. package/localization/it.xlf +553 -0
  98. package/localization/ja.xlf +552 -0
  99. package/localization/ko.xlf +552 -0
  100. package/localization/lt.xlf +552 -0
  101. package/localization/lv.xlf +552 -0
  102. package/localization/nb.xlf +552 -0
  103. package/localization/nl.xlf +552 -0
  104. package/localization/pkg/ar.xliff +7 -0
  105. package/localization/pkg/bg.xliff +7 -0
  106. package/localization/pkg/cs.xliff +7 -0
  107. package/localization/pkg/da.xliff +7 -0
  108. package/localization/pkg/de.xliff +7 -0
  109. package/localization/pkg/el.xliff +7 -0
  110. package/localization/pkg/es.xliff +7 -0
  111. package/localization/pkg/et.xliff +7 -0
  112. package/localization/pkg/fi.xliff +7 -0
  113. package/localization/pkg/fr.xliff +7 -0
  114. package/localization/pkg/hu.xliff +7 -0
  115. package/localization/pkg/id.xliff +7 -0
  116. package/localization/pkg/it.xliff +7 -0
  117. package/localization/pkg/ja.xliff +7 -0
  118. package/localization/pkg/ko.xliff +7 -0
  119. package/localization/pkg/lt.xliff +7 -0
  120. package/localization/pkg/lv.xliff +7 -0
  121. package/localization/pkg/nb.xliff +7 -0
  122. package/localization/pkg/nl.xliff +7 -0
  123. package/localization/pkg/pl.xliff +7 -0
  124. package/localization/pkg/pt-BR.xliff +7 -0
  125. package/localization/pkg/pt-PT.xliff +7 -0
  126. package/localization/pkg/ro.xliff +7 -0
  127. package/localization/pkg/ru.xliff +7 -0
  128. package/localization/pkg/sk.xliff +7 -0
  129. package/localization/pkg/sl.xliff +7 -0
  130. package/localization/pkg/sv.xliff +7 -0
  131. package/localization/pkg/tr.xliff +7 -0
  132. package/localization/pkg/uk.xliff +7 -0
  133. package/localization/pkg/zh-hans.xliff +7 -0
  134. package/localization/pkg/zh-hant.xliff +7 -0
  135. package/localization/pl.xlf +553 -0
  136. package/localization/pt-BR.xlf +553 -0
  137. package/localization/pt-PT.xlf +553 -0
  138. package/localization/ro.xlf +553 -0
  139. package/localization/ru.xlf +553 -0
  140. package/localization/sk.xlf +553 -0
  141. package/localization/sl.xlf +553 -0
  142. package/localization/snippets/ar.xliff +16 -0
  143. package/localization/snippets/bg.xliff +16 -0
  144. package/localization/snippets/cs.xliff +16 -0
  145. package/localization/snippets/da.xliff +16 -0
  146. package/localization/snippets/de.xliff +16 -0
  147. package/localization/snippets/el.xliff +16 -0
  148. package/localization/snippets/es.xliff +16 -0
  149. package/localization/snippets/et.xliff +16 -0
  150. package/localization/snippets/fi.xliff +16 -0
  151. package/localization/snippets/fr.xliff +16 -0
  152. package/localization/snippets/hu.xliff +16 -0
  153. package/localization/snippets/id.xliff +16 -0
  154. package/localization/snippets/it.xliff +16 -0
  155. package/localization/snippets/ja.xliff +16 -0
  156. package/localization/snippets/ko.xliff +16 -0
  157. package/localization/snippets/lt.xliff +16 -0
  158. package/localization/snippets/lv.xliff +16 -0
  159. package/localization/snippets/nb.xliff +16 -0
  160. package/localization/snippets/nl.xliff +16 -0
  161. package/localization/snippets/pl.xliff +16 -0
  162. package/localization/snippets/pt-BR.xliff +16 -0
  163. package/localization/snippets/pt-PT.xliff +16 -0
  164. package/localization/snippets/ro.xliff +16 -0
  165. package/localization/snippets/ru.xliff +16 -0
  166. package/localization/snippets/sk.xliff +16 -0
  167. package/localization/snippets/sl.xliff +16 -0
  168. package/localization/snippets/sv.xliff +16 -0
  169. package/localization/snippets/tr.xliff +16 -0
  170. package/localization/snippets/uk.xliff +16 -0
  171. package/localization/snippets/zh-hans.xliff +16 -0
  172. package/localization/snippets/zh-hant.xliff +16 -0
  173. package/localization/sv.xlf +552 -0
  174. package/localization/tr.xlf +552 -0
  175. package/localization/uk.xlf +552 -0
  176. package/localization/zh-hans.xlf +552 -0
  177. package/localization/zh-hant.xlf +552 -0
  178. package/package.json +103 -2
  179. package/snippets/MNIST.html +21 -0
  180. package/test.json +63 -0
  181. package/tsconfig.json +8 -0
  182. package/widgets/webwriter-feature-engineering.ts +421 -0
  183. package/widgets/webwriter-model-designing.ts +323 -0
  184. package/widgets/webwriter-model-evaluation.ts +215 -0
  185. package/widgets/webwriter-model-prediction.ts +307 -0
  186. package/widgets/webwriter-model-training.ts +709 -0
@@ -0,0 +1,83 @@
1
+ import { SlInput } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer, SIZE_SEP } from "./index";
4
+ import { msg } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private kernelInput: SlInput;
13
+ private strideInput: SlInput;
14
+ private kernelNumInput: SlInput;
15
+ private params: HTMLElement;
16
+
17
+ constructor(fields: TransformedDataset, editor: Editor) {
18
+ super(1, 1, "Convolution", editor)
19
+
20
+ let that = this;
21
+ this.kernelInput = this.addNumberInput(msg("Kernel Size"), 1, 9);
22
+ this.kernelInput.value = "3";
23
+
24
+ this.strideInput = this.addNumberInput(msg("Stride"), 1, 7);
25
+ this.strideInput.onchange = function () {
26
+ that.update();
27
+ that.notifyOutputChange();
28
+ }
29
+ this.strideInput.value = "2";
30
+
31
+ this.kernelNumInput = this.addNumberInput(msg("# of Kernels"), 1, 10);
32
+ this.kernelNumInput.onchange = function () {
33
+ that.update();
34
+ that.notifyOutputChange();
35
+ }
36
+ this.kernelNumInput.value = "4";
37
+
38
+ this.params = document.createElement("span");
39
+ this.addTextElement(msg("Parameters: "), this.params);
40
+ }
41
+ public getNumberOfParameters() {
42
+ this.update();
43
+ return parseInt(this.params.innerText);
44
+ }
45
+ update() {
46
+ this.updateInputLabels();
47
+ let numKernels = parseInt(this.kernelNumInput.value)
48
+ let inDims = this.getNodeInputElement("input_1").innerText.split(SIZE_SEP).map(s => parseInt(s));
49
+ let params = parseInt(this.kernelInput.value) ** 2 * inDims[2] * numKernels + numKernels
50
+ this.params.innerText = String(params);
51
+ this.getNodeOutputElement("output_1").innerText = [Math.ceil(inDims[0] / parseInt(this.strideInput.value)), Math.ceil(inDims[1] / parseInt(this.strideInput.value)), numKernels].join(SIZE_SEP)
52
+ this.notifyOutputChange();
53
+ }
54
+ valid() {
55
+ let numKernels = parseInt(this.kernelNumInput.value)
56
+ let inDims = this.getNodeInputElement("input_1").innerText.split(SIZE_SEP).map(s => parseInt(s));
57
+ let params = parseInt(this.kernelInput.value) ** 2 * inDims[2] * numKernels + numKernels
58
+ this.params.title = params > this.editor.maxLayerParams ? msg("Layer has to many trainable parameters. Try reducing the input size or the tunable properties.") : "";
59
+ return super.valid() && params <= this.editor.maxLayerParams;
60
+ }
61
+ getState() {
62
+ let state = super.getState();
63
+ state.kernel = this.kernelInput.value;
64
+ state.stride = this.strideInput.value;
65
+ state.numkernels = this.kernelNumInput.value;
66
+ state.type = "conv";
67
+ return state;
68
+ }
69
+ setState(state) {
70
+ super.setState(state);
71
+ this.kernelInput.value = state.kernel;
72
+ this.strideInput.value = state.stride;
73
+ this.strideInput.onchange(null);
74
+ this.kernelNumInput.value = state.numkernels;
75
+ this.kernelNumInput.onchange(null);
76
+ }
77
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
78
+ return { output_1: tf.layers.conv2d({ filters:parseInt(this.kernelNumInput.value), kernelSize:parseInt(this.kernelInput.value), strides:parseInt(this.strideInput.value) , padding:"same"}).apply(inputs.input_1) as TF.SymbolicTensor };
79
+ }
80
+ protected getDisplayName(): string {
81
+ return msg("Convolution");
82
+ }
83
+ }
@@ -0,0 +1,44 @@
1
+ import { SlInput } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer, SIZE_SEP } from "./index";
4
+ import { msg } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private rate: SlInput;
13
+ private value: SlInput;
14
+
15
+ constructor(fields: TransformedDataset, editor: Editor) {
16
+ super(1, 1, "Dropout", editor)
17
+
18
+ this.rate = this.addNumberInput(msg("Rate"), 0, 1);
19
+ this.rate.value = "0.1";
20
+ this.rate.step = 0.05;
21
+ }
22
+ update() {
23
+ this.updateInputLabels();
24
+ this.getNodeOutputElement("output_1").innerText = this.getNodeInputElement("input_1").innerText;
25
+ this.notifyOutputChange();
26
+ }
27
+ getState() {
28
+ let state = super.getState();
29
+ state.type = "dropout";
30
+ state.dim = this.getNodeInputElement("input_1").innerText.split(SIZE_SEP).map(v => parseInt(v));
31
+ state.rate = parseFloat(this.rate.value);
32
+ return state;
33
+ }
34
+ setState(state) {
35
+ super.setState(state);
36
+ this.rate.value = state.rate;
37
+ }
38
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
39
+ return { output_1: tf.layers.dropout({rate: parseFloat(this.rate.value) }).apply(inputs.input_1) as TF.SymbolicTensor };
40
+ }
41
+ protected getDisplayName(): string {
42
+ return msg("Dropout");
43
+ }
44
+ }
@@ -0,0 +1,66 @@
1
+ import { SlInput } from "@shoelace-style/shoelace";
2
+ import { TransformedDataset } from '../dataset/dataset';
3
+ import { Editor, Layer } from "./index";
4
+ import { msg } from "@lit/localize";
5
+
6
+ import type * as TF from "@tensorflow/tfjs";
7
+ import getTF from "../../lib/tflib";
8
+ let tf: typeof TF;
9
+ (async () => {tf = await getTF()})()
10
+
11
+ export class ExportLayer extends Layer {
12
+ private dimInput: SlInput;
13
+ private params: HTMLElement;
14
+
15
+ constructor(fields: TransformedDataset, editor: Editor) {
16
+ super(1, 1, "Linear", editor)
17
+
18
+ this.dimInput = this.addNumberInput(msg("Output Nodes"), 1, 500);
19
+ let that = this;
20
+ this.dimInput.oninput = function () {
21
+ that.getNodeOutputElement("output_1").innerText = that.dimInput.value;
22
+ that.update();
23
+ that.notifyOutputChange();
24
+ }
25
+ this.dimInput.value = "50"
26
+
27
+ this.params = document.createElement("span");
28
+ this.addTextElement(msg("Parameters: "), this.params);
29
+ }
30
+ public getNumberOfParameters() {
31
+ this.update();
32
+ return parseInt(this.params.innerText);
33
+ }
34
+ update() {
35
+ this.updateInputLabels();
36
+ let inDim = parseInt(this.getNodeInputElement("input_1").innerText)
37
+ let outDim = parseInt(this.dimInput.value)
38
+ this.params.innerText = String(inDim * outDim + outDim);
39
+ this.notifyOutputChange();
40
+ }
41
+ valid() {
42
+ let inDim = parseInt(this.getNodeInputElement("input_1").innerText)
43
+ let outDim = parseInt(this.dimInput.value)
44
+ let params = inDim * outDim + outDim
45
+ this.params.title = params > this.editor.maxLayerParams ? msg("Layer has to many trainable parameters. Try reducing the input size or the tunable properties.") : "";
46
+ return super.valid() && params <= this.editor.maxLayerParams;
47
+ }
48
+ getState() {
49
+ let state = super.getState();
50
+ state.dim = parseInt(this.dimInput.value);
51
+ state.type = "fcl";
52
+ return state;
53
+ }
54
+
55
+ setState(state) {
56
+ super.setState(state);
57
+ this.dimInput.value = state.dim;
58
+ this.dimInput.oninput(null);
59
+ }
60
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
61
+ return { output_1: tf.layers.dense({ units: parseInt(this.dimInput.value) }).apply(inputs.input_1) as TF.SymbolicTensor };
62
+ }
63
+ protected getDisplayName(): string {
64
+ return msg("Linear");
65
+ }
66
+ }
@@ -0,0 +1,48 @@
1
+ import { TransformedDataset } from '../dataset/dataset';
2
+ import { Editor, Layer, SIZE_SEP } from "./index";
3
+ import { msg } from '@lit/localize';
4
+
5
+ import type * as TF from "@tensorflow/tfjs";
6
+ import getTF from "../../lib/tflib";
7
+ let tf: typeof TF;
8
+ (async () => {tf = await getTF()})()
9
+
10
+ export class ExportLayer extends Layer {
11
+ constructor(fields: TransformedDataset, editor: Editor) {
12
+ super(1, 1, "Flatten", editor)
13
+ }
14
+ update() {
15
+ super.updateInputLabels();
16
+ let inputElems = this.getNodeInputElements();
17
+ let hasInput = false;
18
+ for (let input of inputElems) {
19
+ hasInput = true;
20
+
21
+ let inDims = (input as HTMLElement).innerText.split(SIZE_SEP).map(s => parseInt(s));
22
+ let mult = 1;
23
+ for (let d of inDims) {
24
+ mult *= d;
25
+ }
26
+ this.getNodeOutputElement("output_1").innerText = String(mult);
27
+ }
28
+ if (!hasInput)
29
+ this.getNodeOutputElement("output_1").innerText = "";
30
+
31
+ super.notifyOutputChange();
32
+ }
33
+ getState() {
34
+ let state = super.getState();
35
+ state.dim = [parseInt(this.getNodeOutputElement("output_1").innerText)];
36
+ state.type = "flatten";
37
+ return state;
38
+ }
39
+ setState(state) {
40
+ super.setState(state);
41
+ }
42
+ public forward(inputs: Record<string, TF.SymbolicTensor>): Record<string, TF.SymbolicTensor> {
43
+ return { output_1: tf.layers.flatten().apply(inputs.input_1) as TF.SymbolicTensor };
44
+ }
45
+ protected getDisplayName(): string {
46
+ return msg("Flatten");
47
+ }
48
+ }