Skip to content

Commit

Permalink
Merge cc89611 into 650e66a
Browse files Browse the repository at this point in the history
  • Loading branch information
tkornuta-ibm committed Aug 7, 2019
2 parents 650e66a + cc89611 commit 725af03
Show file tree
Hide file tree
Showing 4 changed files with 398 additions and 1 deletion.
@@ -0,0 +1,60 @@
# This file defines the default values for the MNIST task.

####################################################################
# 1. CONFIGURATION PARAMETERS that will be LOADED by the component.
####################################################################

# Folder where task will store data (LOADED)
data_folder: '~/data/simple-molecules'

# Defines the split that will be used used (LOADED)
# Options: training | validation | test
split: training

# Optional parameter (LOADED)
# When present, resizes the MNIST images from [28,28] to [width, height]
#resize_image: [height, width]

streams:
####################################################################
# 2. Keymappings associated with INPUT and OUTPUT streams.
####################################################################

# Stream containing batch of indices (OUTPUT)
# Every task MUST return that stream.
indices: indices

# Stream containing batch of images (OUTPUT)
images: images

# Stream containing targets (label ids) (OUTPUT)
targets: targets

# Stream containing labels (words) (OUTPUT)
labels: labels

globals:
####################################################################
# 3. Keymappings of variables that will be RETRIEVED from GLOBALS.
####################################################################

####################################################################
# 4. Keymappings associated with GLOBAL variables that will be SET.
####################################################################

# Width of the image (SET)
input_width: image_width
# Height of the image (SET)
input_height: image_height
# Depth of the image (SET)
input_depth: image_depth

# Number of output classes: 10 (SET)
num_classes: num_classes
# Label (word-idx) mappings (SET)
label_word_mappings: label_word_mappings

####################################################################
# 5. Keymappings associated with statistics that will be ADDED.
####################################################################

@@ -0,0 +1,120 @@
# Training parameters:
training:
task:
type: SimpleMolecules
batch_size: &b 64
split: training
# TODO: change!
resize_image: [87, 87]
# TODO: change!
# Use sampler that operates on a subset.
sampler:
type: SubsetRandomSampler
indices: [0, 50000]
# optimizer parameters:
optimizer:
type: Adam
lr: 0.0001
# settings parameters
terminal_conditions:
loss_stop_threshold: 0.15
early_stop_validations: -1
episode_limit: 10000
epoch_limit: 10

# Validation parameters:
validation:
task:
type: SimpleMolecules
batch_size: *b
# TODO: change!
split: training
# TODO: change!
resize_image: [87, 87]
# TODO: change!
# Use sampler that operates on a subset.
sampler:
type: SubsetRandomSampler
indices: [50000, 50400]

# Testing parameters:
test:
task:
type: SimpleMolecules
batch_size: *b
# TODO: change!
split: training
# TODO: change!
resize_image: [87, 87]

pipeline:
# Model 1: 3 CNN layers.
image_encoder:
type: ConvNetEncoder
priority: 1
# Using default stream names, so the following could be removed (leaving it just for the clarity though).
streams:
inputs: images
feature_maps: feature_maps

# Reshape inputs
reshaper:
type: ReshapeTensor
# TODO: change!
#input_dims: [-1, 16, 107, 107]
#output_dims: [-1, 183184]
input_dims: [-1, 16, 9, 9]
output_dims: [-1, 1296]
priority: 2
streams:
inputs: feature_maps
outputs: reshaped_maps
globals:
output_size: reshaped_maps_size

# Model 2: 1 Fully connected layer with softmax acitvation.
classifier:
type: FeedForwardNetwork
priority: 3
streams:
inputs: reshaped_maps
# Using default stream name, so the following could be removed (leaving it just for the clarity though).
predictions: predictions
globals:
input_size: reshaped_maps_size
prediction_size: num_classes

# Loss
nllloss:
type: NLLLoss
priority: 4
# Using default stream names, so the following could be removed (leaving it just for the clarity though).
streams:
targets: targets
predictions: predictions

accuracy:
priority: 5
type: AccuracyStatistics
# Using default stream names, so the following could be removed (leaving it just for the clarity though).
streams:
targets: targets
predictions: predictions

answer_decoder:
priority: 6
type: WordDecoder
import_word_mappings_from_globals: True
globals:
word_mappings: label_word_mappings
streams:
inputs: predictions
outputs: predicted_answers

stream_viewer:
priority: 7
type: StreamViewer
input_streams: labels, targets, predictions, predicted_answers


#: pipeline
4 changes: 3 additions & 1 deletion ptp/components/tasks/image_to_class/__init__.py
@@ -1,8 +1,10 @@
#from .cifar10 import CIFAR10
from .cifar_100 import CIFAR100
from .mnist import MNIST
from .simple_molecules import SimpleMolecules

__all__ = [
'CIFAR100',
'MNIST'
'MNIST',
'SimpleMolecules',
]

0 comments on commit 725af03

Please sign in to comment.