{
  "id": 132286,
  "title": "Modify trainable makes parameter miss?",
  "url": "/competitions/flower-classification-with-tpus/discussion/132286",
  "author_name": "SwordFaith",
  "post_date": "2020-02-25T08:02:35.963000",
  "votes": 1,
  "comment_count": 3,
  "views": 0,
  "content": "<p>I try to port typical warm-up and fine-tune process to my NASNetLarge backbone, I find if I use <code>models.layers[0].trainable=True</code>, the total params seems wrong.\n<img src=\"https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14938/WechatIMG861.png\" alt=\"NASNet result\">\n<code>python\nhistory = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = 1,\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n        model.layers[0].trainable=True\n        model.summary()\n        history = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = EPOCHS,\n            callbacks = [lr_callback],#, early_stopping],\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n</code>\n<img src=\"https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14940/2020-02-2516.00.28.png\" alt=\"rotate kernel got wrong\">\nI do same in <a href=\"https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\">https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96</a>, but wrong as well.\n<img src=\"https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14939/2020-02-2516.00.46.png\" alt=\"rotation kernel normal\"></p>",
  "messages": [
    {
      "id": 755940,
      "postDate": "2020-02-25T09:40:33.173Z",
      "content": "<p><a href=\"/swordfaith\">@swordfaith</a> compile(i.e. do model.compile) the model again after doing model.layers[0].trainable=True, and your problem will be resolved. Thanks</p>",
      "rawMarkdown": "@swordfaith compile(i.e. do model.compile) the model again after doing model.layers[0].trainable=True, and your problem will be resolved. Thanks",
      "votes": 1,
      "replies": [
        {
          "id": 755953,
          "postDate": "2020-02-25T09:50:41.530Z",
          "content": "<p>thank you very much</p>",
          "rawMarkdown": "thank you very much"
        },
        {
          "id": 756795,
          "postDate": "2020-02-26T04:54:26.917Z",
          "rawMarkdown": "",
          "isDeleted": true
        }
      ]
    },
    {
      "id": 755871,
      "postDate": "2020-02-25T08:02:35.963Z",
      "content": "<p>I try to port typical warm-up and fine-tune process to my NASNetLarge backbone, I find if I use <code>models.layers[0].trainable=True</code>, the total params seems wrong.\n<img src=\"https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14938/WechatIMG861.png\" alt=\"NASNet result\">\n<code>python\nhistory = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = 1,\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n        model.layers[0].trainable=True\n        model.summary()\n        history = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = EPOCHS,\n            callbacks = [lr_callback],#, early_stopping],\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n</code>\n<img src=\"https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14940/2020-02-2516.00.28.png\" alt=\"rotate kernel got wrong\">\nI do same in <a href=\"https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96\">https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96</a>, but wrong as well.\n<img src=\"https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14939/2020-02-2516.00.46.png\" alt=\"rotation kernel normal\"></p>",
      "rawMarkdown": "I try to port typical warm-up and fine-tune process to my NASNetLarge backbone, I find if I use `models.layers[0].trainable=True`, the total params seems wrong.\n![NASNet result](https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14938/WechatIMG861.png)\n```python\nhistory = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = 1,\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n        model.layers[0].trainable=True\n        model.summary()\n        history = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = EPOCHS,\n            callbacks = [lr_callback],#, early_stopping],\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n```\n![rotate kernel got wrong](https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14940/2020-02-2516.00.28.png)\nI do same in https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96, but wrong as well.\n![rotation kernel normal](https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14939/2020-02-2516.00.46.png)",
      "votes": 1
    }
  ],
  "comments": [
    {
      "id": 755940,
      "author_name": "Shashank Shekhar",
      "author_url": "",
      "post_date": "2020-02-25T09:40:33.173000",
      "content": "<p><a href=\"/swordfaith\">@swordfaith</a> compile(i.e. do model.compile) the model again after doing model.layers[0].trainable=True, and your problem will be resolved. Thanks</p>",
      "votes": 1,
      "replies": [
        {
          "id": 755953,
          "author_name": "SwordFaith",
          "author_url": "",
          "post_date": "2020-02-25T09:50:41.530000",
          "content": "<p>thank you very much</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 756795,
          "author_name": "",
          "author_url": "",
          "post_date": "2020-02-26T04:54:26.917000",
          "content": "",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "755940": "@swordfaith compile(i.e. do model.compile) the model again after doing model.layers[0].trainable=True, and your problem will be resolved. Thanks",
    "755871": "I try to port typical warm-up and fine-tune process to my NASNetLarge backbone, I find if I use `models.layers[0].trainable=True`, the total params seems wrong.\n![NASNet result](https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14938/WechatIMG861.png)\n```python\nhistory = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = 1,\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n        model.layers[0].trainable=True\n        model.summary()\n        history = model.fit(\n            get_training_dataset(train_dataset), \n            steps_per_epoch = STEPS_PER_EPOCH,\n            epochs = EPOCHS,\n            callbacks = [lr_callback],#, early_stopping],\n            validation_data = get_validation_dataset(val_dataset),\n            verbose=2\n        )\n```\n![rotate kernel got wrong](https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14940/2020-02-2516.00.28.png)\nI do same in https://www.kaggle.com/cdeotte/rotation-augmentation-gpu-tpu-0-96, but wrong as well.\n![rotation kernel normal](https://storage.googleapis.com/kaggle-forum-message-attachments/755871/14939/2020-02-2516.00.46.png)"
  }
}