Icon

03. Train Model - solution

Annotations and comments
  • Train a U-Net For Option 1: Create a conda environment for Keras under Preferences -> KNIME -> Python Deep Learning For Option 2: Use the conda environment for Tensorflow2, which was already create in the previous exercise
  • Option 1: Train a Unet using No-Code nodes 1. Partition your data using the Partitioning node (Settings: Relative partitioning size 80%, Draw randomly) 2. Read in your U-Net from the previous exercise using the Keras Network Reader node 3. Use the Conda Environment Propagation node to ensure the correct conda environment (use the Keras environment created in the beginning under Preferences) is selected. 4. Use the Keras Network Learner node to train the model %%00009- connections: %%00009%%00009- use the training data (upper output port from the Partitioning node) as input %%00009%%00009- use the model from the Keras Network Reader as model input %%00009%%00009- connect the conda environment flow variable from the Conda Environment Propagation node to the Flow Variable input port %%00009- Node Settings: %%00009%%00009- input column: preprocessed image column "Img Calc" %%00009%%00009- target column: preprocessed label column "Label Calc" %%00009%%00009- options: epochs: 15, training batch size: 5, optimizer: Adam %%00009%%00009- Executable Selection tab: select conda environment flow variable 5. Use the Keras Network Executor node to predict on the test data %%00009- Node settings: %%00009%%00009- input columns: preprocessed image column "Img Calc" %%00009%%00009- add output: select "conv2d_19/Sigmoid:0", Conversion: "To Image", rename column "output" %%00009%%00009- Executable Selection tab: select conda environment flow variable 6. Use Model Writer node to save your trained model to a file named trained.model in the data folder %%00009(Hint: use workflow relative path: ../../data/trained.model) 7. Use the Interactive Segmentation View node to evaluate your prediction results
  • Option 2: Train a Unet using DL Python nodes 1. Partition your data using the Partitioning node (Settings: Relative partitioning size 80%, Draw randomly) 2. Use the Conda Environment Propagation node to ensure the correct conda environment (use the Tensorflow2 environment created in the beginning under Preferences) is selected. 3. Read in your U-Net from the previous exercise using the Tensorflow2 Network Reader node %%00009- Node Settings: %%00009%%00009- Executable Selection tab: select conda environment flow variable 4. Use the DL Python Network Learner node to train the model %%00009- connections: %%00009%%00009- use the training data (upper output port from the Partitioning node) as input %%00009%%00009- use the model from the Tensorflow2 Network Reader as model input %%00009%%00009- connect the conda environment flow variable from the Conda Environment Propagation node to the Flow Variable input port %%00009- Node Settings: %%00009%%00009- Executable Selection tab: select conda environment flow variable 5. Use the Tensorflow2 Network Executor node to predict on the test data %%00009- Node settings: %%00009%%00009- input columns: preprocessed image column "Img Calc" %%00009%%00009- add output: select "conv2d_19/Sigmoid:0", Conversion: "To Image", rename column "output" %%00009%%00009- Executable Selection tab: select conda environment flow variable 6. Use Tensorflow2 Network Writer node to save your trained model to a file named trained_tf2.h5 in the data folder and check "Save optimizer state" %%00009(Hint: use workflow relative path: ../../data/trained_tf2.h5) 7. Use the Interactive Segmentation View node to evaluate your prediction results
  • Epoch: 15
  • convert labelings to byte
  • predicted labels
  • u-net.h5
  • trained.model
  • training data
  • u-net-tf2.h5
  • trained_tf2.h5

Nodes

Extensions

Links