learning_model 1.0.31 → 1.0.33

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.
@@ -291,13 +291,22 @@ class LearningMobilenet {
291
291
  return __awaiter(this, void 0, void 0, function* () {
292
292
  try {
293
293
  const truncatedModel = yield this.loadModel();
294
- console.log('truncatedModel', truncatedModel, truncatedModel.outputs[0].shape.slice(1));
295
294
  // 입력 이미지 크기에 맞게 모델 구조 수정
296
295
  const model = tf.sequential();
297
- model.add(tf.layers.flatten({
296
+ // 추가적인 합성곱 층
297
+ model.add(tf.layers.conv2d({
298
+ filters: 64,
299
+ kernelSize: 3,
300
+ activation: 'relu',
301
+ padding: 'same',
298
302
  inputShape: truncatedModel.outputs[0].shape.slice(1)
299
303
  }));
304
+ model.add(tf.layers.flatten());
305
+ // 더 깊은 밀집층
300
306
  model.add(tf.layers.dense({ units: 100, activation: 'relu' }));
307
+ model.add(tf.layers.dense({ units: 100, activation: 'relu' }));
308
+ // 드롭아웃 층
309
+ model.add(tf.layers.dropout({ rate: 0.5 }));
301
310
  model.add(tf.layers.dense({ units: this.labels.length, activation: 'softmax' }));
302
311
  const optimizer = tf.train.adam(this.learningRate); // Optimizer를 생성하고 학습률을 설정합니다.
303
312
  model.compile({
@@ -293,15 +293,29 @@ class LearningMobilenet implements LearningInterface {
293
293
  private async _createModel(numClasses: number): Promise<tf.Sequential> {
294
294
  try {
295
295
  const truncatedModel = await this.loadModel()
296
- console.log('truncatedModel', truncatedModel, truncatedModel.outputs[0].shape.slice(1));
297
296
  // 입력 이미지 크기에 맞게 모델 구조 수정
298
297
  const model = tf.sequential();
299
- model.add(tf.layers.flatten({
298
+ // 추가적인 합성곱 층
299
+ model.add(tf.layers.conv2d({
300
+ filters: 64,
301
+ kernelSize: 3,
302
+ activation: 'relu',
303
+ padding: 'same',
300
304
  inputShape: truncatedModel.outputs[0].shape.slice(1)
301
305
  }));
306
+
307
+ model.add(tf.layers.flatten());
308
+
309
+ // 더 깊은 밀집층
310
+ model.add(tf.layers.dense({ units: 100, activation: 'relu' }));
302
311
  model.add(tf.layers.dense({ units: 100, activation: 'relu' }));
312
+
313
+ // 드롭아웃 층
314
+ model.add(tf.layers.dropout({ rate: 0.5 }));
315
+
303
316
  model.add(tf.layers.dense({ units: this.labels.length, activation: 'softmax' }));
304
317
 
318
+
305
319
  const optimizer = tf.train.adam(this.learningRate); // Optimizer를 생성하고 학습률을 설정합니다.
306
320
  model.compile({
307
321
  loss: (numClasses === 2) ? 'binaryCrossentropy': 'categoricalCrossentropy',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learning_model",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "learning model develop",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",