Skip to content
Back to skills

Sensor Modality Dropout

ASecurity

Randomly zero out entire sensor modalities during training with a learned gate to handle missing modalities at inference

  • 61 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 12, 2026
developmentpython

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill sensor-modality-dropout --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sensor Modality Dropout?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sensor Modality Dropout
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-sensor-modality-dropout/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-sensor-modality-dropout)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: timeseries-sensor-modality-dropout
description: Randomly zero out entire sensor modalities during training with a learned gate to handle missing modalities at inference
domain: timeseries
---

# Sensor Modality Dropout

## Overview

In multi-sensor systems, some modalities may be missing at inference time (sensor failure, power saving). Train robustness by randomly zeroing entire modality channels with probability p, while a gating network learns to predict whether a modality is active. At inference, the gate automatically downweights missing modalities.

## Quick Start

```python
import torch
import torch.nn as nn
import numpy as np

class ModalityDropout(nn.Module):
    def __init__(self, n_channels, drop_prob=0.3):
        super().__init__()
        self.drop_prob = drop_prob
        self.gate = nn.Sequential(
            nn.AdaptiveAvgPool1d(1), nn.Flatten(),
            nn.Linear(n_channels, 16), nn.ReLU(),
            nn.Linear(16, 1), nn.Sigmoid()
        )

    def forward(self, x):  # x: (B, C, T)
        gate_val = self.gate(x)  # (B, 1)
        if self.training:
            mask = (torch.rand(x.size(0), 1, 1, device=x.device) > self.drop_prob).float()
            x = x * mask
        return x * gate_val.unsqueeze(2)
```

## Key Decisions

- **drop_prob=0.3**: aggressive enough to learn robustness, not so much that primary signal is lost
- **Learned gate**: sigmoid output scales the modality contribution based on signal quality
- **Drop entire modality**: zero all channels of a sensor, not individual channels — simulates real failure modes
- **Gate supervision optional**: can add auxiliary BCE loss on gate output vs mask target

## References

- Source: [cmi-detect-behavior-with-sensor-data](https://www.kaggle.com/code/nina2025/cmi-detect-behavior-with-sensor-data)
- Competition: CMI - Detect Behavior with Sensor Data

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.