ruvnet/ruflo · error

Invalid dropout: ${this.config.dropout}. Must be between 0 a

Error message

Invalid dropout: ${this.config.dropout}. Must be between 0 and 1.

What it means

BaseGNNLayer.validateConfig() (gnn.ts:488) enforces dropout to lie in [0, 1], since dropout is a probability. Values below 0 or above 1 are rejected at construction; 0 and 1 themselves are allowed. Defaults come from GNN_DEFAULTS when unset, so this only triggers on an explicitly supplied out-of-range value.

Source

Thrown at v3/@claude-flow/plugins/src/integrations/ruvector/gnn.ts:488

  constructor(config: GNNLayerConfig) {
    this.type = config.type;
    this.config = config;
    this.validateConfig();
  }

  /**
   * Validate layer configuration.
   * @throws Error if configuration is invalid
   */
  protected validateConfig(): void {
    if (this.config.inputDim <= 0) {
      throw new Error(`Invalid inputDim: ${this.config.inputDim}. Must be positive.`);
    }
    if (this.config.outputDim <= 0) {
      throw new Error(`Invalid outputDim: ${this.config.outputDim}. Must be positive.`);
    }
    if (this.config.dropout !== undefined && (this.config.dropout < 0 || this.config.dropout > 1)) {
      throw new Error(`Invalid dropout: ${this.config.dropout}. Must be between 0 and 1.`);
    }
    if (this.config.numHeads !== undefined && this.config.numHeads <= 0) {
      throw new Error(`Invalid numHeads: ${this.config.numHeads}. Must be positive.`);
    }
  }

  abstract forward(graph: GraphData): Promise<GNNOutput>;
  abstract messagePass(nodes: NodeFeatures, edges: EdgeFeatures): Promise<NodeFeatures>;

  /**
   * Aggregate messages using the specified method.
   */
  async aggregate(messages: Message[], method: AggregationMethod): Promise<number[]> {
    if (messages.length === 0) {
      return new Array(this.config.outputDim).fill(0);
    }

    const vectors = messages.map((m) => m.vector);

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Express dropout as a fraction in [0, 1] (0.2 for 20%)
  2. If your config uses percentages, convert before constructing: dropout: cfg.dropoutPct / 100
  3. Clamp sweep values: Math.min(1, Math.max(0, d)) when a stray value is acceptable

Example fix

// before
const layer = new GCNLayer({ type: 'gcn', inputDim: 128, outputDim: 64, dropout: 20 }); // 20% as int -> throws

// after
const layer = new GCNLayer({ type: 'gcn', inputDim: 128, outputDim: 64, dropout: 0.2 });
Defensive patterns

Strategy: validation

Validate before calling

if (cfg.dropout !== undefined && (cfg.dropout < 0 || cfg.dropout > 1)) {
  throw new RangeError(`dropout must be within [0,1], got ${cfg.dropout}`);
}
const layer = registry.createLayer('gat', cfg);

Type guard

function isValidDropout(v: unknown): v is number {
  return typeof v === 'number' && v >= 0 && v <= 1;
}

Try / catch

try {
  layer = new GATLayer(config);
} catch (err) {
  if (err instanceof Error && err.message.includes('Invalid dropout')) {
    config = { ...config, dropout: Math.min(1, Math.max(0, config.dropout)) };
    layer = new GATLayer(config);
  } else throw err;
}

Prevention

When it happens

Trigger: new GATLayer({ type: 'gat', dropout: 1.5, ... }); passing a percentage (e.g. 20 for 20%) instead of a fraction; hyperparameter sweeps stepping outside [0,1]; env/CLI config parsed with an extra decimal shift.

Common situations: Config authored as percent rather than probability; ML framework porting where dropout semantics differ; typo like 0.55 vs 5.5.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/2fe1a5708306f41e. Report an issue: GitHub.