• Arindam Jati's avatar
    [Time series] Add PatchTSMixer (#26247) · b242d0f2
    Arindam Jati authored
    
    
    * patchtsmixer initial commit
    
    * x,y->context_values,target_values, unittest addded
    
    * cleanup code
    
    * minor
    
    * return hidden states
    
    * model tests, partial integration tests
    
    * ettm notebook temporary
    
    * minor
    
    * config mask bug fix, tests updated
    
    * final ETT notebooks
    
    * add selfattn
    
    * init
    
    * added docstrings
    
    * PatchTSMixerForPretraining -> PatchTSMixerForMaskPretraining
    
    * functionality tests added
    
    * add start and input docstrings
    
    * docstring edits
    
    * testcase edits
    
    * minor changes
    
    * docstring error fixed
    
    * ran make fixup
    
    * finalize integration tests and docs
    
    * minor
    
    * cleaned gitignore
    
    * added dataclass decorator, ran black formatter
    
    * ran ruff
    
    * formatting
    
    * add slow decorator
    
    * renamed in_Channel to input_size and default to 1
    
    * shorten dataclass names
    
    * use smaller model for testing
    
    * moved the 3 heads to the modeling file
    
    * use scalers instead of revin
    
    * support forecast_channel_indices
    
    * fix regression scaling
    
    * undo reg. scaling
    
    * removed unneeded classes
    
    * forgot missing
    
    * add more layers
    
    * add copied positional_encoding
    
    * use patchmask from patchtst
    
    * removed dependency on layers directory
    
    * formatting
    
    * set seed
    
    * removed unused imports
    
    * fixed forward signature test
    
    * adding distributional head for PatchTSMixerForecasting
    
    * add generate to forecast
    
    * testcases for generate
    
    * add generate and distributional head for regression
    
    * raise Exception for negative values for neg binominal distribution
    
    * formatting changes
    
    * remove copied from patchtst and add TODO for test passing
    
    * make copies
    
    * doc edits
    
    * minor changes
    
    * format issues
    
    * minor changes
    
    * minor changes
    
    * format docstring
    
    * change some class names to PatchTSMixer + class name
    
    Transpose to PatchTSMixerTranspose
    GatedAttention to PatchTSMixerGatedAttention
    
    * change NormLayer to PatchTSMixerNormLayer
    
    * change MLP to PatchTSMixerMLP
    
    * change PatchMixer to PatchMixerBlock, FeatureMixer to FeatureMixerBlock
    
    * change ChannelFeatureMixer to ChannelFeatureMixerBlock
    
    * change PatchMasking to PatchTSMixerMasking
    
    * change Patchify to PatchTSMixerPatchify
    
    * list to `list`
    
    * fix docstrings
    
    * formatting
    
    * change bs to batch_size, edit forecast_masking
    
    * edit random_masking
    
    * change variable name and update docstring in PatchTSMixerMasking
    
    * change variable name and update docstring in InjectScalerStatistics4D
    
    * update forward call in PatchTSMixerTranspose
    
    * change variable name and update docstring in PatchTSMixerNormLayer
    
    * change variable name and update docstring in PatchTSMixerMLP
    
    * change variable name and update docstring in ChannelFeatureMixerBlock
    
    * formatting
    
    * formatting issues
    
    * docstring issue
    
    * fixed observed_mask type in docstrings
    
    * use FloatTensor type
    
    * formatting
    
    * fix rescaling issue in forecasting, fixed integration tests
    
    * add docstring from decorator
    
    * fix docstring
    
    * Update README.md
    
    Co-authored-by: default avatarNielsRogge <48327001+NielsRogge@users.noreply.github.com>
    
    * Update src/transformers/models/patchtsmixer/configuration_patchtsmixer.py
    
    Co-authored-by: default avatarNielsRogge <48327001+NielsRogge@users.noreply.github.com>
    
    * Update src/transformers/models/patchtsmixer/modeling_patchtsmixer.py
    
    Co-authored-by: default avatarNielsRogge <48327001+NielsRogge@users.noreply.github.com>
    
    * Update src/transformers/models/patchtsmixer/configuration_patchtsmixer.py
    
    Co-authored-by: default avatarNielsRogge <48327001+NielsRogge@users.noreply.github.com>
    
    * Update src/transformers/models/patchtsmixer/modeling_patchtsmixer.py
    
    Co-authored-by: default avatarNielsRogge <48327001+NielsRogge@users.noreply.github.com>
    
    * PatchTSMixerChannelFeatureMixerBlock
    
    * formatting
    
    * ForPretraining
    
    * use num_labels instead of n_classes
    
    * remove commented out code
    
    * docstring fixed
    
    * nn.functional used instead of one letter F
    
    * x_tmp renamed
    
    * one letter variable x removed from forward calls
    
    * one letter variable y removed
    
    * remove commented code
    
    * rename patch_size, in_channels, PatchTSMixerBackbone
    
    * add config to heads
    
    * add config to heads tests
    
    * code reafactoring to use config instead of passing individual params
    
    * Cdocstring fixes part 1
    
    * docstring fixes part 2
    
    * removed logger.debug
    
    * context_values -> past_values
    
    * formatting changes
    
    * pe -> positional_encoding
    
    * removed unused target variable
    
    * self.mode logic fixed
    
    * formatting change
    
    * edit docstring and var name
    
    * change n_targets to num_targets
    
    * rename input_size to num_input_channels
    
    * add head names with prefix PatchTSMixer
    
    * edit docstring in PatchTSMixerForRegression
    
    * fix var name change in testcases
    
    * add PatchTSMixerAttention
    
    * return dict for all exposed classes, test cases added
    
    * format
    
    * move loss function to forward call
    
    * make style
    
    * adding return dict/tuple
    
    * make repo-consistency
    
    * remove flatten mode
    
    * code refactoring
    
    * rename data
    
    * remove PatchTSMixer and keep only PatchTSMixerEncoder
    
    * docstring fixes
    
    * removed unused code
    
    * format
    
    * format
    
    * remove contiguous and formatting changes
    
    * remove model description from config
    
    * replace asserts with ValueError
    
    * remove nn.Sequential from PatchTSMixerNormLayer
    
    * replace if-else with map
    
    * remove all nn.Sequential
    
    * format
    
    * formatting
    
    * fix gradient_checkpointing error after merge, and formatting
    
    * make fix-copies
    
    * remove comments
    
    * reshape
    
    * doesnt support gradient checkpointing
    
    * corect Patchify
    
    * masking updates
    
    * batchnorm copy from
    
    * format checks
    
    * scaler edits
    
    * remove comments
    
    * format changes
    
    * remove self.config
    
    * correct class PatchTSMixerMLP(nn.Module):
    
    * makr fix
    
    * doc updates
    
    * fix-copies
    
    * scaler class correction
    
    * doc edits
    
    * scaler edits
    
    * update readme with links
    
    * injectstatistics add
    
    * fix-copies
    
    * add norm_eps option to LayerNorm
    
    * format changes
    
    * fix copies
    
    * correct make copies
    
    * use parametrize
    
    * fix doc string
    
    * add docs to toctree
    
    * make style
    
    * doc segmenting
    
    * docstring edit
    
    * change forecast to prediction
    
    * edit doc
    
    * doc edits
    
    * remove PatchTSMixerTranspose
    
    * add PatchTSMixerPositionalEncoding and init position_enc
    
    * remove positional_encoding
    
    * edit forecast_masking, remove forecast_mask_ratios
    
    * fix broken code
    
    * var rename target_values -> future_values
    
    * num_features -> d_model
    
    * fix broken code after master merge
    
    * repo consistency
    
    * use postional embedding
    
    * prediction_logits -> prediction_outputs, make fix-copies
    
    * uncommented @slow
    
    * minor changes
    
    * loss first in tuple
    
    * tuple and dict same ordering
    
    * style edits
    
    * minor changes
    
    * dict/tuple consistent enablement
    
    * Update src/transformers/models/patchtsmixer/modeling_patchtsmixer.py
    
    Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
    
    * Update tests/models/patchtsmixer/test_modeling_patchtsmixer.py
    
    Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
    
    * Update src/transformers/models/patchtsmixer/modeling_patchtsmixer.py
    
    Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
    
    * fix formatting
    
    * formatting
    
    * usage tip
    
    * test on cpu only
    
    * add sample usage
    
    * change PatchTSMixerForClassification to PatchTSMixerForTimeSeriesClassification
    
    * push changes
    
    * fix copies
    
    * std scaling set to default True case
    
    * minor changes
    
    * stylechanges
    
    ---------
    
    Co-authored-by: default avatarArindam Jati <arindam.jati@ibm.com>
    Co-authored-by: default avatarvijaye12 <vijaye12@in.ibm.com>
    Co-authored-by: default avatarKashif Rasul <kashif.rasul@gmail.com>
    Co-authored-by: default avatarnnguyen <nnguyen@us.ibm.com>
    Co-authored-by: default avatarvijaye12 <vijaykr.e@gmail.com>
    Co-authored-by: default avatarNielsRogge <48327001+NielsRogge@users.noreply.github.com>
    Co-authored-by: default avatarNam Nguyen <namctin@gmail.com>
    Co-authored-by: default avatarWesley Gifford <79663411+wgifford@users.noreply.github.com>
    Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
    b242d0f2