Class CNTKSaver

  • All Implemented Interfaces:
    Serializable, weka.core.CapabilitiesHandler, weka.core.CapabilitiesIgnorer, weka.core.converters.BatchConverter, weka.core.converters.FileSourcedConverter, weka.core.converters.Saver, weka.core.EnvironmentHandler, weka.core.OptionHandler, weka.core.RevisionHandler

    public class CNTKSaver
    extends weka.core.converters.AbstractFileSaver
    implements weka.core.converters.BatchConverter
    Writes the Instances to a CNTK text file.
    Automatically turns a nominal class attribute into CNTK's '1-hot encoding'.

    Valid options are:

     -D <value>
      Whether to print additional debug information to the console.
      (default: off)
     -row-id <value>
      The (optional) attribute to use for the row ID.
      (default: )
     -inputs <value>
      The attribute ranges determining the inputs (eg for 'features' and 'class').
      (default: )
     -input-names <value>
      The names of the inputs (eg 'features' and 'class').
      (default: )
     -use-sparse-format <value>
      If enabled, sparse format is used instead (ie 'index:value').
      (default: no)
     -suppress-missing <value>
      If enabled, groups that contain at least one missing value get suppressed completely.
      (default: no)
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean m_Debug
      whether to print some debug information
      protected adams.core.base.BaseString[] m_InputNames
      the names of the inputs.
      protected adams.core.Range[] m_Inputs
      the inputs.
      protected Locale m_Locale
      the locale to use.
      protected File m_OutputFile
      the file to write to.
      protected adams.core.Index m_RowID
      the optional row id attribute.
      protected boolean m_SuppressMissing
      whether to suppress groups with missing values.
      protected boolean m_UseSparseFormat
      whether to output sparse format.
      • Fields inherited from class weka.core.converters.AbstractFileSaver

        m_env, m_incrementalCounter, m_useRelativePath
      • Fields inherited from class weka.core.converters.AbstractSaver

        CANCEL, m_DoNotCheckCapabilities, m_retrieval, STRUCTURE_READY, WAIT, WRITE
      • Fields inherited from interface weka.core.converters.Saver

        BATCH, INCREMENTAL, NONE
    • Constructor Summary

      Constructors 
      Constructor Description
      CNTKSaver()
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String debugTipText()
      the tip text for this property
      protected String format​(double value)
      Formats the number according to the format and returns the generated textual representation.
      weka.core.Capabilities getCapabilities()
      Returns the Capabilities of this saver.
      boolean getDebug()
      Gets whether additional debug information is printed.
      protected adams.core.base.BaseString[] getDefaultInputNames()
      Returns the default input names.
      protected adams.core.Range[] getDefaultInputs()
      Returns the default input ranges.
      protected adams.core.Index getDefaultRowID()
      Returns the default attribute index to use as row ID.
      String getFileDescription()
      Returns a description of the file type.
      String[] getFileExtensions()
      Gets all the file extensions used for this type of file
      adams.core.base.BaseString[] getInputNames()
      Returns the names for the inputs.
      adams.core.Range[] getInputs()
      Returns the attribute ranges that make up the inputs (eg for 'features' and 'class').
      String[] getOptions()
      returns the options of the current setup
      String getRevision()
      Returns the revision string.
      adams.core.Index getRowID()
      Returns the (optional) attribute to use as row ID.
      boolean getSuppressMissing()
      Returns whether to suppress groups with missing values.
      boolean getUseSparseFormat()
      Returns whether to use sparse format.
      String globalInfo()
      Returns a string describing this Saver
      String inputNamesTipText()
      Returns the tip text for this property.
      String inputsTipText()
      Returns the tip text for this property.
      Enumeration listOptions()
      Returns an enumeration describing the available options.
      static void main​(String[] args)
      Main method.
      void resetOptions()  
      String rowIDTipText()
      Returns the tip text for this property
      void setDebug​(boolean value)
      Sets whether to print some debug information.
      void setDestination​(File file)
      Sets the destination file (and directories if necessary).
      void setDestination​(OutputStream output)
      Default implementation throws an IOException.
      void setInputNames​(adams.core.base.BaseString[] value)
      Sets the names for the inputs.
      void setInputs​(adams.core.Range[] value)
      Sets the attribute ranges that make up the inputs (eg for 'features' and 'class').
      void setOptions​(String[] options)
      Parses the options for this object.
      void setRowID​(adams.core.Index value)
      Sets the (optional) attribute to use as row ID.
      void setSuppressMissing​(boolean value)
      Sets whether to suppress groups with missing values.
      void setUseSparseFormat​(boolean value)
      Sets whether to use sparse format.
      String suppressMissingTipText()
      Returns the tip text for this property.
      String useSparseFormatTipText()
      Returns the tip text for this property.
      void writeBatch()
      Writes a Batch of instances
      • Methods inherited from class weka.core.converters.AbstractFileSaver

        cancel, filePrefix, getFileExtension, getUseRelativePath, getWriter, makeOptionStr, resetWriter, retrieveDir, retrieveFile, runFileSaver, setDir, setDirAndPrefix, setEnvironment, setFile, setFileExtension, setFilePrefix, setUseRelativePath, useRelativePathTipText
      • Methods inherited from class weka.core.converters.AbstractSaver

        doNotCheckCapabilitiesTipText, getDoNotCheckCapabilities, getInstances, getRetrieval, getWriteMode, resetStructure, setDoNotCheckCapabilities, setInstances, setRetrieval, setStructure, setWriteMode, writeIncremental
    • Field Detail

      • m_Debug

        protected boolean m_Debug
        whether to print some debug information
      • m_RowID

        protected adams.core.Index m_RowID
        the optional row id attribute.
      • m_Inputs

        protected adams.core.Range[] m_Inputs
        the inputs.
      • m_InputNames

        protected adams.core.base.BaseString[] m_InputNames
        the names of the inputs.
      • m_UseSparseFormat

        protected boolean m_UseSparseFormat
        whether to output sparse format.
      • m_SuppressMissing

        protected boolean m_SuppressMissing
        whether to suppress groups with missing values.
      • m_OutputFile

        protected File m_OutputFile
        the file to write to.
      • m_Locale

        protected Locale m_Locale
        the locale to use.
    • Constructor Detail

      • CNTKSaver

        public CNTKSaver()
        Constructor
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing this Saver
        Returns:
        a description of the Saver suitable for displaying in the explorer/experimenter gui
      • resetOptions

        public void resetOptions()
        Overrides:
        resetOptions in class weka.core.converters.AbstractFileSaver
      • listOptions

        public Enumeration listOptions()
        Returns an enumeration describing the available options.
        Specified by:
        listOptions in interface weka.core.OptionHandler
        Overrides:
        listOptions in class weka.core.converters.AbstractFileSaver
        Returns:
        an enumeration of all the available options.
      • setOptions

        public void setOptions​(String[] options)
                        throws Exception
        Parses the options for this object.
        Specified by:
        setOptions in interface weka.core.OptionHandler
        Overrides:
        setOptions in class weka.core.converters.AbstractFileSaver
        Parameters:
        options - the options to use
        Throws:
        Exception - if setting of options fails
      • getOptions

        public String[] getOptions()
        returns the options of the current setup
        Specified by:
        getOptions in interface weka.core.OptionHandler
        Overrides:
        getOptions in class weka.core.converters.AbstractFileSaver
        Returns:
        the current options
      • getFileDescription

        public String getFileDescription()
        Returns a description of the file type.
        Specified by:
        getFileDescription in interface weka.core.converters.FileSourcedConverter
        Specified by:
        getFileDescription in class weka.core.converters.AbstractFileSaver
        Returns:
        a short file description
      • getFileExtensions

        public String[] getFileExtensions()
        Gets all the file extensions used for this type of file
        Specified by:
        getFileExtensions in interface weka.core.converters.FileSourcedConverter
        Overrides:
        getFileExtensions in class weka.core.converters.AbstractFileSaver
        Returns:
        the file extensions
      • setDebug

        public void setDebug​(boolean value)
        Sets whether to print some debug information.
        Parameters:
        value - if true additional debug information will be printed.
      • getDebug

        public boolean getDebug()
        Gets whether additional debug information is printed.
        Returns:
        true if additional debug information is printed
      • debugTipText

        public String debugTipText()
        the tip text for this property
        Returns:
        the tip text
      • getDefaultRowID

        protected adams.core.Index getDefaultRowID()
        Returns the default attribute index to use as row ID.
        Returns:
        the default
      • setRowID

        public void setRowID​(adams.core.Index value)
        Sets the (optional) attribute to use as row ID.
        Parameters:
        value - the index
      • getRowID

        public adams.core.Index getRowID()
        Returns the (optional) attribute to use as row ID.
        Returns:
        the index
      • rowIDTipText

        public String rowIDTipText()
        Returns the tip text for this property
        Returns:
        tip text for this property suitable for displaying in the explorer/experimenter gui
      • getDefaultInputs

        protected adams.core.Range[] getDefaultInputs()
        Returns the default input ranges.
        Returns:
        the default
      • setInputs

        public void setInputs​(adams.core.Range[] value)
        Sets the attribute ranges that make up the inputs (eg for 'features' and 'class').
        Parameters:
        value - the attribute
      • getInputs

        public adams.core.Range[] getInputs()
        Returns the attribute ranges that make up the inputs (eg for 'features' and 'class').
        Returns:
        the ranges
      • inputsTipText

        public String inputsTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getDefaultInputNames

        protected adams.core.base.BaseString[] getDefaultInputNames()
        Returns the default input names.
        Returns:
        the default
      • setInputNames

        public void setInputNames​(adams.core.base.BaseString[] value)
        Sets the names for the inputs.
        Parameters:
        value - the names
      • getInputNames

        public adams.core.base.BaseString[] getInputNames()
        Returns the names for the inputs.
        Returns:
        the names
      • inputNamesTipText

        public String inputNamesTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setUseSparseFormat

        public void setUseSparseFormat​(boolean value)
        Sets whether to use sparse format.
        Parameters:
        value - true if to use sparse format
      • getUseSparseFormat

        public boolean getUseSparseFormat()
        Returns whether to use sparse format.
        Returns:
        true if to use sparse format
      • useSparseFormatTipText

        public String useSparseFormatTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSuppressMissing

        public void setSuppressMissing​(boolean value)
        Sets whether to suppress groups with missing values.
        Parameters:
        value - true if to suppress missing
      • getSuppressMissing

        public boolean getSuppressMissing()
        Returns whether to suppress groups with missing values.
        Returns:
        true if to suppress missing
      • suppressMissingTipText

        public String suppressMissingTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getCapabilities

        public weka.core.Capabilities getCapabilities()
        Returns the Capabilities of this saver.
        Specified by:
        getCapabilities in interface weka.core.CapabilitiesHandler
        Overrides:
        getCapabilities in class weka.core.converters.AbstractSaver
        Returns:
        the capabilities of this object
        See Also:
        Capabilities
      • setDestination

        public void setDestination​(File file)
                            throws IOException
        Sets the destination file (and directories if necessary).
        Specified by:
        setDestination in interface weka.core.converters.Saver
        Overrides:
        setDestination in class weka.core.converters.AbstractFileSaver
        Parameters:
        file - the File
        Throws:
        IOException - always
      • setDestination

        public void setDestination​(OutputStream output)
                            throws IOException
        Default implementation throws an IOException.
        Specified by:
        setDestination in interface weka.core.converters.Saver
        Overrides:
        setDestination in class weka.core.converters.AbstractFileSaver
        Parameters:
        output - the OutputStream
        Throws:
        IOException - always
      • format

        protected String format​(double value)
        Formats the number according to the format and returns the generated textual representation.
        Parameters:
        value - the double value to turn into a string
        Returns:
        the generated string
      • writeBatch

        public void writeBatch()
                        throws IOException
        Writes a Batch of instances
        Specified by:
        writeBatch in interface weka.core.converters.Saver
        Specified by:
        writeBatch in class weka.core.converters.AbstractSaver
        Throws:
        IOException - throws IOException if saving in batch mode is not possible
      • getRevision

        public String getRevision()
        Returns the revision string.
        Specified by:
        getRevision in interface weka.core.RevisionHandler
        Returns:
        the revision
      • main

        public static void main​(String[] args)
        Main method.
        Parameters:
        args - should contain the options of a Saver.