@webwriter/deep-learning-model 0.0.1 → 1.0.1
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.
- package/.github/workflows/main.yml +8 -0
- package/LICENSE +7 -0
- package/README.md +290 -0
- package/components/dataset-input/dataset-input.styles.ts +20 -0
- package/components/dataset-input/dataset-input.ts +196 -0
- package/components/inference-fields/class-input.ts +83 -0
- package/components/inference-fields/class-output.ts +62 -0
- package/components/inference-fields/image-input.ts +182 -0
- package/components/inference-fields/image.ts +82 -0
- package/components/inference-fields/inference-interfaces.ts +15 -0
- package/components/inference-fields/number-input.ts +62 -0
- package/components/inference-fields/number-output.ts +56 -0
- package/components/model-editor.ts +273 -0
- package/components/model-tests/bad-samples.ts +152 -0
- package/components/model-tests/loss-distribution.ts +174 -0
- package/components/reference-element-select.ts +105 -0
- package/custom-elements.json +1446 -0
- package/custom.d.ts +180 -0
- package/dist/widgets/webwriter-feature-engineering.css +444 -0
- package/dist/widgets/webwriter-feature-engineering.js +112241 -0
- package/dist/widgets/webwriter-model-designing.css +444 -0
- package/dist/widgets/webwriter-model-designing.js +113967 -0
- package/dist/widgets/webwriter-model-evaluation.css +444 -0
- package/dist/widgets/webwriter-model-evaluation.js +119019 -0
- package/dist/widgets/webwriter-model-prediction.css +444 -0
- package/dist/widgets/webwriter-model-prediction.js +109260 -0
- package/dist/widgets/webwriter-model-training.css +444 -0
- package/dist/widgets/webwriter-model-training.js +121391 -0
- package/editing-config.json +73 -0
- package/icon.svg +1 -0
- package/lib/dataset/class.ts +155 -0
- package/lib/dataset/dataset.ts +293 -0
- package/lib/dataset/feature.ts +110 -0
- package/lib/dataset/image.ts +312 -0
- package/lib/dataset/linear.ts +120 -0
- package/lib/layers/activation.ts +48 -0
- package/lib/layers/add.ts +50 -0
- package/lib/layers/attention.ts +74 -0
- package/lib/layers/concat.ts +50 -0
- package/lib/layers/conv.ts +83 -0
- package/lib/layers/dropout.ts +44 -0
- package/lib/layers/fcl.ts +66 -0
- package/lib/layers/flatten.ts +48 -0
- package/lib/layers/index.ts +708 -0
- package/lib/layers/input.ts +55 -0
- package/lib/layers/noise.ts +43 -0
- package/lib/layers/output.ts +64 -0
- package/lib/layers/reshape.ts +76 -0
- package/lib/layers/transposeconv.ts +90 -0
- package/lib/tflib.ts +6 -0
- package/lit-localize.json +47 -0
- package/localization/ar.xlf +532 -0
- package/localization/bg.xlf +531 -0
- package/localization/cs.xlf +532 -0
- package/localization/da.xlf +531 -0
- package/localization/de.xlf +531 -0
- package/localization/el.xlf +533 -0
- package/localization/es.xlf +532 -0
- package/localization/et.xlf +532 -0
- package/localization/fi.xlf +531 -0
- package/localization/fr.xlf +532 -0
- package/localization/generated/ar.ts +158 -0
- package/localization/generated/bg.ts +157 -0
- package/localization/generated/cs.ts +158 -0
- package/localization/generated/da.ts +157 -0
- package/localization/generated/de.ts +157 -0
- package/localization/generated/el.ts +159 -0
- package/localization/generated/es.ts +158 -0
- package/localization/generated/et.ts +158 -0
- package/localization/generated/fi.ts +157 -0
- package/localization/generated/fr.ts +158 -0
- package/localization/generated/hu.ts +157 -0
- package/localization/generated/id.ts +158 -0
- package/localization/generated/index.js +3 -0
- package/localization/generated/it.ts +158 -0
- package/localization/generated/ja.ts +157 -0
- package/localization/generated/ko.ts +157 -0
- package/localization/generated/locale-codes.js +83 -0
- package/localization/generated/lt.ts +157 -0
- package/localization/generated/lv.ts +157 -0
- package/localization/generated/nb.ts +157 -0
- package/localization/generated/nl.ts +157 -0
- package/localization/generated/pl.ts +158 -0
- package/localization/generated/pt-BR.ts +158 -0
- package/localization/generated/pt-PT.ts +158 -0
- package/localization/generated/ro.ts +158 -0
- package/localization/generated/ru.ts +158 -0
- package/localization/generated/sk.ts +158 -0
- package/localization/generated/sl.ts +158 -0
- package/localization/generated/sv.ts +157 -0
- package/localization/generated/tr.ts +157 -0
- package/localization/generated/uk.ts +157 -0
- package/localization/generated/zh-hans.ts +140 -0
- package/localization/generated/zh-hant.ts +140 -0
- package/localization/hu.xlf +531 -0
- package/localization/id.xlf +532 -0
- package/localization/it.xlf +532 -0
- package/localization/ja.xlf +531 -0
- package/localization/ko.xlf +531 -0
- package/localization/lt.xlf +531 -0
- package/localization/lv.xlf +531 -0
- package/localization/nb.xlf +531 -0
- package/localization/nl.xlf +531 -0
- package/localization/pkg/ar.xliff +7 -0
- package/localization/pkg/bg.xliff +7 -0
- package/localization/pkg/cs.xliff +7 -0
- package/localization/pkg/da.xliff +7 -0
- package/localization/pkg/de.xliff +7 -0
- package/localization/pkg/el.xliff +7 -0
- package/localization/pkg/es.xliff +7 -0
- package/localization/pkg/et.xliff +7 -0
- package/localization/pkg/fi.xliff +7 -0
- package/localization/pkg/fr.xliff +7 -0
- package/localization/pkg/hu.xliff +7 -0
- package/localization/pkg/id.xliff +7 -0
- package/localization/pkg/it.xliff +7 -0
- package/localization/pkg/ja.xliff +7 -0
- package/localization/pkg/ko.xliff +7 -0
- package/localization/pkg/lt.xliff +7 -0
- package/localization/pkg/lv.xliff +7 -0
- package/localization/pkg/nb.xliff +7 -0
- package/localization/pkg/nl.xliff +7 -0
- package/localization/pkg/pl.xliff +7 -0
- package/localization/pkg/pt-BR.xliff +7 -0
- package/localization/pkg/pt-PT.xliff +7 -0
- package/localization/pkg/ro.xliff +7 -0
- package/localization/pkg/ru.xliff +7 -0
- package/localization/pkg/sk.xliff +7 -0
- package/localization/pkg/sl.xliff +7 -0
- package/localization/pkg/sv.xliff +7 -0
- package/localization/pkg/tr.xliff +7 -0
- package/localization/pkg/uk.xliff +7 -0
- package/localization/pkg/zh-hans.xliff +7 -0
- package/localization/pkg/zh-hant.xliff +7 -0
- package/localization/pl.xlf +532 -0
- package/localization/pt-BR.xlf +532 -0
- package/localization/pt-PT.xlf +532 -0
- package/localization/ro.xlf +532 -0
- package/localization/ru.xlf +532 -0
- package/localization/sk.xlf +532 -0
- package/localization/sl.xlf +532 -0
- package/localization/snippets/ar.xliff +16 -0
- package/localization/snippets/bg.xliff +16 -0
- package/localization/snippets/cs.xliff +16 -0
- package/localization/snippets/da.xliff +16 -0
- package/localization/snippets/de.xliff +16 -0
- package/localization/snippets/el.xliff +16 -0
- package/localization/snippets/es.xliff +16 -0
- package/localization/snippets/et.xliff +16 -0
- package/localization/snippets/fi.xliff +16 -0
- package/localization/snippets/fr.xliff +16 -0
- package/localization/snippets/hu.xliff +16 -0
- package/localization/snippets/id.xliff +16 -0
- package/localization/snippets/it.xliff +16 -0
- package/localization/snippets/ja.xliff +16 -0
- package/localization/snippets/ko.xliff +16 -0
- package/localization/snippets/lt.xliff +16 -0
- package/localization/snippets/lv.xliff +16 -0
- package/localization/snippets/nb.xliff +16 -0
- package/localization/snippets/nl.xliff +16 -0
- package/localization/snippets/pl.xliff +16 -0
- package/localization/snippets/pt-BR.xliff +16 -0
- package/localization/snippets/pt-PT.xliff +16 -0
- package/localization/snippets/ro.xliff +16 -0
- package/localization/snippets/ru.xliff +16 -0
- package/localization/snippets/sk.xliff +16 -0
- package/localization/snippets/sl.xliff +16 -0
- package/localization/snippets/sv.xliff +16 -0
- package/localization/snippets/tr.xliff +16 -0
- package/localization/snippets/uk.xliff +16 -0
- package/localization/snippets/zh-hans.xliff +16 -0
- package/localization/snippets/zh-hant.xliff +16 -0
- package/localization/sv.xlf +531 -0
- package/localization/tr.xlf +531 -0
- package/localization/uk.xlf +531 -0
- package/localization/zh-hans.xlf +531 -0
- package/localization/zh-hant.xlf +531 -0
- package/package.json +104 -3
- package/snippets/MNIST.html +21 -0
- package/test.json +63 -0
- package/tsconfig.json +8 -0
- package/widgets/webwriter-feature-engineering.ts +421 -0
- package/widgets/webwriter-model-designing.ts +300 -0
- package/widgets/webwriter-model-evaluation.ts +215 -0
- package/widgets/webwriter-model-prediction.ts +307 -0
- package/widgets/webwriter-model-training.ts +684 -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
|
+
}
|