wuhp commited on
Commit
af2b42a
·
verified ·
1 Parent(s): 270baa2

Update constants.ts

Browse files
Files changed (1) hide show
  1. constants.ts +240 -1
constants.ts CHANGED
@@ -26,7 +26,7 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
26
  { name: 'in_features', type: 'number', label: 'In Features (Opt)', default: 0, description: "0 = Auto-infer" },
27
  { name: 'out_features', type: 'number', label: 'Output Features', default: 128 },
28
  { name: 'bias', type: 'boolean', label: 'Use Bias', default: true },
29
- { name: 'activation', type: 'select', label: 'Fused Activation', default: 'None', options: ['None', 'ReLU', 'GELU', 'Sigmoid'] }
30
  ]
31
  },
32
  [LayerType.OUTPUT]: {
@@ -62,6 +62,119 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
62
  ]
63
  },
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  // --- GRAPH NEURAL NETWORKS ---
66
  [LayerType.GCN_CONV]: {
67
  type: LayerType.GCN_CONV,
@@ -745,6 +858,50 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
745
  category: 'Merge',
746
  parameters: []
747
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
 
749
  // --- GENAI / ADVANCED ---
750
  [LayerType.RMSNORM]: {
@@ -885,6 +1042,29 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
885
  { name: 'padding', type: 'number', label: 'Padding', default: 1 }
886
  ]
887
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
888
  [LayerType.CONV_TRANSPOSE2D]: {
889
  type: LayerType.CONV_TRANSPOSE2D,
890
  label: 'ConvTranspose2D',
@@ -1067,6 +1247,20 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
1067
  category: 'Utility',
1068
  parameters: []
1069
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1070
  [LayerType.DROPOUT]: {
1071
  type: LayerType.DROPOUT,
1072
  label: 'Dropout',
@@ -1076,6 +1270,15 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
1076
  { name: 'p', type: 'number', label: 'Probability', default: 0.5 }
1077
  ]
1078
  },
 
 
 
 
 
 
 
 
 
1079
  [LayerType.DROPPATH]: {
1080
  type: LayerType.DROPPATH,
1081
  label: 'DropPath',
@@ -1132,6 +1335,15 @@ export const LAYER_DEFINITIONS: Record<LayerType, LayerDefinition> = {
1132
  { name: 'definition_code', type: 'text', label: 'Python Code (Def)', default: '', description: "Full class definition if strictly custom." }
1133
  ]
1134
  },
 
 
 
 
 
 
 
 
 
1135
  [LayerType.IDENTITY]: {
1136
  type: LayerType.IDENTITY,
1137
  label: 'Identity',
@@ -1281,6 +1493,33 @@ export const INITIAL_EDGES = [
1281
  ];
1282
 
1283
  export const TEMPLATES: Record<string, GraphTemplate> = {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1284
  'rvc_voice': {
1285
  id: 'rvc_voice',
1286
  name: 'Voice Cloning (RVC)',
 
26
  { name: 'in_features', type: 'number', label: 'In Features (Opt)', default: 0, description: "0 = Auto-infer" },
27
  { name: 'out_features', type: 'number', label: 'Output Features', default: 128 },
28
  { name: 'bias', type: 'boolean', label: 'Use Bias', default: true },
29
+ { name: 'activation', type: 'select', label: 'Fused Activation', default: 'None', options: ['None', 'ReLU', 'GELU', 'Sigmoid', 'Softplus'] }
30
  ]
31
  },
32
  [LayerType.OUTPUT]: {
 
62
  ]
63
  },
64
 
65
+ // --- PREPROCESSING (TF/KERAS STYLE) ---
66
+ [LayerType.RESCALING]: {
67
+ type: LayerType.RESCALING,
68
+ label: 'Rescaling',
69
+ description: 'Scale inputs (x * scale + offset)',
70
+ category: 'Preprocessing',
71
+ parameters: [
72
+ { name: 'scale', type: 'number', label: 'Scale', default: 0.00392, description: 'e.g. 1/255' },
73
+ { name: 'offset', type: 'number', label: 'Offset', default: 0.0 }
74
+ ]
75
+ },
76
+ [LayerType.RESIZING]: {
77
+ type: LayerType.RESIZING,
78
+ label: 'Resizing',
79
+ description: 'Resize image batch',
80
+ category: 'Preprocessing',
81
+ parameters: [
82
+ { name: 'height', type: 'number', label: 'Height', default: 224 },
83
+ { name: 'width', type: 'number', label: 'Width', default: 224 },
84
+ { name: 'interpolation', type: 'select', label: 'Interpolation', default: 'bilinear', options: ['bilinear', 'nearest', 'bicubic'] }
85
+ ]
86
+ },
87
+ [LayerType.CENTER_CROP]: {
88
+ type: LayerType.CENTER_CROP,
89
+ label: 'Center Crop',
90
+ description: 'Crops the central portion',
91
+ category: 'Preprocessing',
92
+ parameters: [
93
+ { name: 'height', type: 'number', label: 'Height', default: 224 },
94
+ { name: 'width', type: 'number', label: 'Width', default: 224 }
95
+ ]
96
+ },
97
+ [LayerType.NORMALIZATION_LAYER]: {
98
+ type: LayerType.NORMALIZATION_LAYER,
99
+ label: 'Normalization (Stat)',
100
+ description: 'Normalize with mean/variance (Keras style)',
101
+ category: 'Preprocessing',
102
+ parameters: [
103
+ { name: 'mean', type: 'string', label: 'Mean', default: '0.0' },
104
+ { name: 'variance', type: 'string', label: 'Variance', default: '1.0' },
105
+ { name: 'axis', type: 'number', label: 'Axis', default: -1 }
106
+ ]
107
+ },
108
+ [LayerType.RANDOM_FLIP]: {
109
+ type: LayerType.RANDOM_FLIP,
110
+ label: 'Random Flip',
111
+ description: 'Augmentation: Flips image',
112
+ category: 'Preprocessing',
113
+ parameters: [
114
+ { name: 'mode', type: 'select', label: 'Mode', default: 'horizontal', options: ['horizontal', 'vertical', 'horizontal_and_vertical'] },
115
+ { name: 'seed', type: 'number', label: 'Seed', default: 42 }
116
+ ]
117
+ },
118
+ [LayerType.RANDOM_ROTATION]: {
119
+ type: LayerType.RANDOM_ROTATION,
120
+ label: 'Random Rotation',
121
+ description: 'Augmentation: Rotates image',
122
+ category: 'Preprocessing',
123
+ parameters: [
124
+ { name: 'factor', type: 'number', label: 'Factor (0-1)', default: 0.2 },
125
+ { name: 'fill_mode', type: 'select', label: 'Fill Mode', default: 'reflect', options: ['reflect', 'wrap', 'constant', 'nearest'] }
126
+ ]
127
+ },
128
+ [LayerType.RANDOM_ZOOM]: {
129
+ type: LayerType.RANDOM_ZOOM,
130
+ label: 'Random Zoom',
131
+ description: 'Augmentation: Zooms image',
132
+ category: 'Preprocessing',
133
+ parameters: [
134
+ { name: 'height_factor', type: 'number', label: 'Height Factor', default: 0.2 },
135
+ { name: 'width_factor', type: 'number', label: 'Width Factor', default: 0.2 }
136
+ ]
137
+ },
138
+ [LayerType.RANDOM_CONTRAST]: {
139
+ type: LayerType.RANDOM_CONTRAST,
140
+ label: 'Random Contrast',
141
+ description: 'Augmentation: Adjusts contrast',
142
+ category: 'Preprocessing',
143
+ parameters: [
144
+ { name: 'factor', type: 'number', label: 'Factor', default: 0.1 }
145
+ ]
146
+ },
147
+ [LayerType.TEXT_VECTORIZATION]: {
148
+ type: LayerType.TEXT_VECTORIZATION,
149
+ label: 'Text Vectorization',
150
+ description: 'Map text to integer sequences',
151
+ category: 'Preprocessing',
152
+ parameters: [
153
+ { name: 'max_tokens', type: 'number', label: 'Max Tokens', default: 10000 },
154
+ { name: 'output_sequence_length', type: 'number', label: 'Seq Length', default: 256 },
155
+ { name: 'output_mode', type: 'select', label: 'Mode', default: 'int', options: ['int', 'binary', 'count', 'tf_idf'] }
156
+ ]
157
+ },
158
+ [LayerType.DISCRETIZATION]: {
159
+ type: LayerType.DISCRETIZATION,
160
+ label: 'Discretization',
161
+ description: 'Bucketizes continuous features',
162
+ category: 'Preprocessing',
163
+ parameters: [
164
+ { name: 'num_bins', type: 'number', label: 'Num Bins', default: 10 }
165
+ ]
166
+ },
167
+ [LayerType.CATEGORY_ENCODING]: {
168
+ type: LayerType.CATEGORY_ENCODING,
169
+ label: 'Category Encoding',
170
+ description: 'One-hot or Multi-hot encoding',
171
+ category: 'Preprocessing',
172
+ parameters: [
173
+ { name: 'num_tokens', type: 'number', label: 'Num Tokens', default: 10 },
174
+ { name: 'output_mode', type: 'select', label: 'Mode', default: 'one_hot', options: ['one_hot', 'multi_hot', 'count'] }
175
+ ]
176
+ },
177
+
178
  // --- GRAPH NEURAL NETWORKS ---
179
  [LayerType.GCN_CONV]: {
180
  type: LayerType.GCN_CONV,
 
858
  category: 'Merge',
859
  parameters: []
860
  },
861
+ [LayerType.SUBTRACT]: {
862
+ type: LayerType.SUBTRACT,
863
+ label: 'Subtract',
864
+ description: 'Element-wise subtraction',
865
+ category: 'Merge',
866
+ parameters: []
867
+ },
868
+ [LayerType.MULTIPLY]: {
869
+ type: LayerType.MULTIPLY,
870
+ label: 'Multiply',
871
+ description: 'Element-wise multiplication',
872
+ category: 'Merge',
873
+ parameters: []
874
+ },
875
+ [LayerType.AVERAGE]: {
876
+ type: LayerType.AVERAGE,
877
+ label: 'Average',
878
+ description: 'Average of inputs',
879
+ category: 'Merge',
880
+ parameters: []
881
+ },
882
+ [LayerType.MAXIMUM]: {
883
+ type: LayerType.MAXIMUM,
884
+ label: 'Maximum',
885
+ description: 'Element-wise maximum',
886
+ category: 'Merge',
887
+ parameters: []
888
+ },
889
+ [LayerType.MINIMUM]: {
890
+ type: LayerType.MINIMUM,
891
+ label: 'Minimum',
892
+ description: 'Element-wise minimum',
893
+ category: 'Merge',
894
+ parameters: []
895
+ },
896
+ [LayerType.DOT]: {
897
+ type: LayerType.DOT,
898
+ label: 'Dot Product',
899
+ description: 'Dot product of two tensors',
900
+ category: 'Merge',
901
+ parameters: [
902
+ { name: 'axes', type: 'number', label: 'Axis', default: 1 }
903
+ ]
904
+ },
905
 
906
  // --- GENAI / ADVANCED ---
907
  [LayerType.RMSNORM]: {
 
1042
  { name: 'padding', type: 'number', label: 'Padding', default: 1 }
1043
  ]
1044
  },
1045
+ [LayerType.SEPARABLE_CONV2D]: {
1046
+ type: LayerType.SEPARABLE_CONV2D,
1047
+ label: 'Separable Conv2D',
1048
+ description: 'Depthwise Separable Conv (TF/Keras style)',
1049
+ category: 'Convolution',
1050
+ parameters: [
1051
+ { name: 'out_channels', type: 'number', label: 'Filters', default: 64 },
1052
+ { name: 'kernel_size', type: 'number', label: 'Kernel Size', default: 3 },
1053
+ { name: 'depth_multiplier', type: 'number', label: 'Depth Mult', default: 1 },
1054
+ { name: 'stride', type: 'number', label: 'Stride', default: 1 }
1055
+ ]
1056
+ },
1057
+ [LayerType.DEPTHWISE_CONV2D]: {
1058
+ type: LayerType.DEPTHWISE_CONV2D,
1059
+ label: 'Depthwise Conv2D',
1060
+ description: 'Convolution per channel independently',
1061
+ category: 'Convolution',
1062
+ parameters: [
1063
+ { name: 'kernel_size', type: 'number', label: 'Kernel Size', default: 3 },
1064
+ { name: 'depth_multiplier', type: 'number', label: 'Depth Mult', default: 1 },
1065
+ { name: 'stride', type: 'number', label: 'Stride', default: 1 }
1066
+ ]
1067
+ },
1068
  [LayerType.CONV_TRANSPOSE2D]: {
1069
  type: LayerType.CONV_TRANSPOSE2D,
1070
  label: 'ConvTranspose2D',
 
1247
  category: 'Utility',
1248
  parameters: []
1249
  },
1250
+ [LayerType.SOFTPLUS]: {
1251
+ type: LayerType.SOFTPLUS,
1252
+ label: 'Softplus',
1253
+ description: 'Smooth approximation to ReLU',
1254
+ category: 'Utility',
1255
+ parameters: []
1256
+ },
1257
+ [LayerType.SOFTSIGN]: {
1258
+ type: LayerType.SOFTSIGN,
1259
+ label: 'Softsign',
1260
+ description: 'Softsign Activation',
1261
+ category: 'Utility',
1262
+ parameters: []
1263
+ },
1264
  [LayerType.DROPOUT]: {
1265
  type: LayerType.DROPOUT,
1266
  label: 'Dropout',
 
1270
  { name: 'p', type: 'number', label: 'Probability', default: 0.5 }
1271
  ]
1272
  },
1273
+ [LayerType.SPATIAL_DROPOUT]: {
1274
+ type: LayerType.SPATIAL_DROPOUT,
1275
+ label: 'Spatial Dropout',
1276
+ description: 'Drops entire 2D feature maps',
1277
+ category: 'Utility',
1278
+ parameters: [
1279
+ { name: 'p', type: 'number', label: 'Probability', default: 0.2 }
1280
+ ]
1281
+ },
1282
  [LayerType.DROPPATH]: {
1283
  type: LayerType.DROPPATH,
1284
  label: 'DropPath',
 
1335
  { name: 'definition_code', type: 'text', label: 'Python Code (Def)', default: '', description: "Full class definition if strictly custom." }
1336
  ]
1337
  },
1338
+ [LayerType.LAMBDA]: {
1339
+ type: LayerType.LAMBDA,
1340
+ label: 'Lambda (Expr)',
1341
+ description: 'Evaluate custom expression (e.g. x * 2)',
1342
+ category: 'Utility',
1343
+ parameters: [
1344
+ { name: 'expression', type: 'string', label: 'Expression', default: 'x', description: "Python expression using 'x'" }
1345
+ ]
1346
+ },
1347
  [LayerType.IDENTITY]: {
1348
  type: LayerType.IDENTITY,
1349
  label: 'Identity',
 
1493
  ];
1494
 
1495
  export const TEMPLATES: Record<string, GraphTemplate> = {
1496
+ 'mobilenet_block': {
1497
+ id: 'mobilenet_block',
1498
+ name: 'MobileNet Block',
1499
+ description: 'Efficient Separable Conv (TF/Keras style).',
1500
+ nodes: [
1501
+ { id: 'in', type: 'custom', position: {x: 250, y: 0}, data: {label: 'Input', type: LayerType.INPUT, params: {modality: 'Image'}} },
1502
+ // Expansion
1503
+ { id: 'pw1', type: 'custom', position: {x: 250, y: 100}, data: {label: '1x1 Conv (Expand)', type: LayerType.CONV2D, params: {out_channels: 144, kernel_size: 1}} },
1504
+ { id: 'bn1', type: 'custom', position: {x: 250, y: 200}, data: {label: 'BatchNorm', type: LayerType.BATCHNORM, params: {}} },
1505
+ { id: 'rel1', type: 'custom', position: {x: 250, y: 300}, data: {label: 'ReLU6', type: LayerType.RELU, params: {}} }, // Typically ReLU6
1506
+ // Depthwise
1507
+ { id: 'dw', type: 'custom', position: {x: 250, y: 400}, data: {label: 'Depthwise Conv', type: LayerType.DEPTHWISE_CONV2D, params: {kernel_size: 3, stride: 1}} },
1508
+ { id: 'bn2', type: 'custom', position: {x: 250, y: 500}, data: {label: 'BatchNorm', type: LayerType.BATCHNORM, params: {}} },
1509
+ { id: 'rel2', type: 'custom', position: {x: 250, y: 600}, data: {label: 'ReLU6', type: LayerType.RELU, params: {}} },
1510
+ // Pointwise
1511
+ { id: 'pw2', type: 'custom', position: {x: 250, y: 700}, data: {label: '1x1 Conv (Project)', type: LayerType.CONV2D, params: {out_channels: 24, kernel_size: 1}} },
1512
+ { id: 'bn3', type: 'custom', position: {x: 250, y: 800}, data: {label: 'BatchNorm', type: LayerType.BATCHNORM, params: {}} },
1513
+ // Residual
1514
+ { id: 'add', type: 'custom', position: {x: 250, y: 900}, data: {label: 'Add Residual', type: LayerType.ADD, params: {}} },
1515
+ ],
1516
+ edges: [
1517
+ { id: '1', source: 'in', target: 'pw1' }, { id: '2', source: 'pw1', target: 'bn1' }, { id: '3', source: 'bn1', target: 'rel1' },
1518
+ { id: '4', source: 'rel1', target: 'dw' }, { id: '5', source: 'dw', target: 'bn2' }, { id: '6', source: 'bn2', target: 'rel2' },
1519
+ { id: '7', source: 'rel2', target: 'pw2' }, { id: '8', source: 'pw2', target: 'bn3' },
1520
+ { id: '9', source: 'bn3', target: 'add' }, { id: '10', source: 'in', target: 'add' }
1521
+ ]
1522
+ },
1523
  'rvc_voice': {
1524
  id: 'rvc_voice',
1525
  name: 'Voice Cloning (RVC)',