instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Write docstrings for data processing functions | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -40,6 +40,7 @@
def set_death_signal():
+ """Kill the current process when the parent process exits."""
if platform.system() != "Linux":
return
libc = ctypes.CDLL("libc.so.6")
@@ -64,6 +65,10 @@
def get_vllm_max_lora_rank(lora_rank: int):
+ """
+ For vLLM, automatically adj... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/rollout/vllm_rollout/utils.py |
Fill in missing docstrings in my code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -65,6 +65,14 @@ checkpoint_config: CheckpointConfig,
**kwargs,
):
+ """
+ Initialize the VeOmniEngine.
+
+ Sets up distributed device meshes, LoRA, and offload policies based on config.
+
+ Args:
+ config: Configuration object with VeOmni and model... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/engine/veomni/transformer_impl.py |
Create docstrings for API functions | # Copyright 2025 z.ai
# Copyright 2023-2024 SGLang Team
# Copyright 2025 ModelBest Inc. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lic... | --- +++ @@ -31,6 +31,18 @@ # - Improved logging and monitoring capabilities
# - Additional configuration options and optimizations
+"""HTTP Server Engine Adapter for SGLang.
+
+This module provides HTTP-based adapters for SGLang engines, allowing communication
+with SGLang servers through HTTP requests instead of di... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/rollout/sglang_rollout/http_server_engine.py |
Generate missing documentation strings | import os
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from dataclasses import dataclass, field
from typing import Union, Optional
from mcp.server.fastmcp import Context, FastMCP
from gpt_oss.tools.simple_browser import SimpleBrowserTool
from gpt_oss.tools.simple_browser.backend... | --- +++ @@ -59,6 +59,7 @@ query: str,
topn: int = 10,
source: Optional[str] = None) -> str:
+ """Search for information related to a query"""
browser = ctx.request_context.lifespan_context.create_or_get_browser(
ctx.client_id)
messages = []
@@ -... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt-oss-mcp-server/browser_server.py |
Add docstrings that explain purpose and usage | import os
from collections import defaultdict
from multiprocessing.pool import ThreadPool
from typing import Any, Callable
import jinja2
import numpy as np
from tqdm import tqdm
from .types import EvalResult, Message, SingleEvalResult
HTML_JINJA = """
<h3>Prompt conversation</h3>
{% for message in prompt_messages %... | --- +++ @@ -48,6 +48,9 @@ default_stats: tuple[str, ...] = ("mean", "std"),
name2stats: dict[str, tuple[str]] | None = None,
) -> EvalResult:
+ """
+ Aggregate results from multiple evaluations into a single EvalResult.
+ """
name2stats = name2stats or {}
name2values = defaultdict(list)
... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/evals/report.py |
Please document this code using docstrings | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -77,6 +77,11 @@
class vLLMHttpServer:
+ """vLLM http server in single node, this is equivalent to launch server with command line:
+ ```
+ vllm serve --tensor-parallel-size=8 ...
+ ```
+ """
def __init__(
self,
@@ -90,6 +95,17 @@ nnodes: int,
cuda_visible_d... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/rollout/vllm_rollout/vllm_async_server.py |
Add inline docstrings for readability | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -37,6 +37,12 @@
class NoOpDataLoader(BaseDataLoader):
+ """A no-op dataloader for use when verl manages its own data loading.
+
+ Satisfies the BaseDataLoader interface required by torchtitan's Trainer
+ but does nothing. Its __iter__ yields nothing, and state_dict /
+ load_state_dict are no-... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/engine/torchtitan/utils.py |
Add clean documentation to messy code | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -48,6 +48,7 @@
def _with_routing_replay_flag(enabled: bool):
+ """Decorator to set 'enable_routing_replay' flag on the data TensorDict."""
def decorator(func):
@functools.wraps(func)
@@ -62,6 +63,11 @@
class TrainingWorker(Worker, DistProfilerExtension):
+ """
+ TrainingWorke... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/engine_workers.py |
Write docstrings for backend logic | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,20 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+The vllm_rollout that can be applied in different backend
+When working with FSDP:
+- Use DTensor weight lo... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/rollout/vllm_rollout/vllm_rollout.py |
Write docstrings describing each step |
import argparse
import copy
import hashlib
import json
import random
import re
from collections import defaultdict
from datetime import datetime
from pathlib import Path
from typing import Literal
import blobfile as bf
import numpy as np
from . import report
from .chat_completions_sampler import (
OPENAI_SYSTEM_... | --- +++ @@ -1,3 +1,15 @@+"""
+This script evaluates the performance of a model on the HealthBench dataset.
+
+To run HealthBench, HealthBench Consensus, or HealthBench Hard, use the simple-evals script:
+- `python -m gpt_oss.evals --eval=healthbench --model=gpt-oss-120b`
+- `python -m gpt_oss.evals --eval=healthbench_c... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/evals/healthbench_eval.py |
Add docstrings to clarify complex logic | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -27,6 +27,10 @@
def enable_full_determinism(seed: int):
+ """
+ Helper function for reproducibility in distributed training.
+ See https://pytorch.org/docs/stable/notes/randomness.html for details.
+ """
os.environ["PYTHONHASHSEED"] = str(seed)
os.environ["CUBLAS_WORKSPACE_CONFIG"... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/engine/utils.py |
Add docstrings to improve collaboration | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,14 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+In single GPU rollout, the sequences are generated directly by sampling from the model.
+The output will co... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/rollout/naive/naive_rollout.py |
Write docstrings for this repository | #!/usr/bin/env python3
from __future__ import annotations
import pathlib
from dataclasses import dataclass, field
from enum import Enum
from typing import (
Callable,
Dict,
List,
Optional,
Tuple,
Union,
)
# --------------------------------------------------------------------------- #
# Dom... | --- +++ @@ -1,5 +1,11 @@ #!/usr/bin/env python3
+"""
+A self-contained **pure-Python 3.9+** utility for applying human-readable
+“pseudo-diff” patch files to a collection of text files.
+
+Source: https://cookbook.openai.com/examples/gpt4-1_prompting_guide
+"""
from __future__ import annotations
@@ -42,6 +48,7 @... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/tools/apply_patch.py |
Document this code for team use |
from typing import Callable
from gpt_oss.metal import Context, Model
# Tunables
MAX_OUTPUT_TOKENS = 100
def setup_model(checkpoint: str) -> Callable[[list[int], float], int]:
model = Model(checkpoint)
context = Context(model)
seed = 0
output_tokens = []
def infer_next_token(
tokens:... | --- +++ @@ -1,3 +1,4 @@+"""Metal backend for :mod:`gpt_oss.responses_api`."""
from typing import Callable
@@ -9,6 +10,7 @@
def setup_model(checkpoint: str) -> Callable[[list[int], float], int]:
+ """Load the Metal model and return an inference function."""
model = Model(checkpoint)
context = Con... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/responses_api/inference/metal.py |
Create simple docstrings for beginners | from dataclasses import dataclass, field
from typing import Any, Literal, overload
Message = dict[str, Any] # keys role, content
MessageList = list[Message]
@dataclass
class SamplerResponse:
response_text: str
actual_queried_message_list: MessageList
response_metadata: dict[str, Any]
class SamplerBase... | --- +++ @@ -8,11 +8,18 @@
@dataclass
class SamplerResponse:
+ """
+ Response from a sampler.
+ """
response_text: str
actual_queried_message_list: MessageList
response_metadata: dict[str, Any]
class SamplerBase:
+ """
+ Base class for defining a sampling model, which can be evaluated... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/evals/types.py |
Document classes and their methods | import os
import torch
import torch.distributed as dist
def suppress_output(rank):
import builtins as __builtin__
builtin_print = __builtin__.print
def print(*args, **kwargs):
force = kwargs.pop('force', False)
if force:
builtin_print("rank #%d:" % rank, *args, **kwargs)
... | --- +++ @@ -4,6 +4,7 @@
def suppress_output(rank):
+ """Suppress printing on the current device. Force printing with `force=True`."""
import builtins as __builtin__
builtin_print = __builtin__.print
@@ -18,6 +19,7 @@
def init_distributed() -> torch.device:
+ """Initialize the model for distrib... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/torch/utils.py |
Add docstrings that explain inputs and outputs |
import os
from typing import Callable, List
# Transformers imports
from transformers import AutoModelForCausalLM, PreTrainedModel
import torch
DEFAULT_TEMPERATURE = 0.0
TP = os.environ.get("TP", 2)
def load_model(checkpoint: str):
model = AutoModelForCausalLM.from_pretrained(
checkpoint,
torch... | --- +++ @@ -1,3 +1,7 @@+"""
+NOTE: this is not the most efficient way to use transformers. It's a simple implementation that infers
+one token at a time to mimic the behavior of the Triton implementation.
+"""
import os
from typing import Callable, List
@@ -11,6 +15,9 @@ TP = os.environ.get("TP", 2)
def load_mod... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/responses_api/inference/transformers.py |
Add docstrings to meet PEP guidelines | # Run this before running the tool:
# $ docker image pull python:3.11
import asyncio
import contextlib
import io
import os
import queue
import subprocess
import tarfile
import tempfile
from pathlib import Path
from typing import Any, AsyncIterator
import docker
from openai_harmony import (
Author,
Content,
... | --- +++ @@ -39,6 +39,9 @@
def call_python_script(script: str) -> str:
+ """
+ Call a python script by writing it to a file in the container and executing it.
+ """
global _docker_client
if _docker_client is None:
_docker_client = docker.from_env()
@@ -77,6 +80,10 @@
def call_python_s... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/tools/python_docker/docker_tool.py |
Generate docstrings with parameter types | from abc import ABC, abstractmethod
from uuid import UUID, uuid4
from typing import AsyncIterator
from openai_harmony import (
Author,
Role,
Message,
TextContent,
)
def _maybe_update_inplace_and_validate_channel(
*, input_message: Message, tool_message: Message
) -> None:
# If the channel of ... | --- +++ @@ -26,16 +26,41 @@
class Tool(ABC):
+ """
+ Something the model can call.
+
+ Tools expose APIs that are shown to the model in a syntax that the model
+ understands and knows how to call (from training data). Tools allow the
+ model to do things like run code, browse the web, etc.
+ """
... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/tools/tool.py |
Generate docstrings for exported functions |
import os
from typing import Callable, List, Optional
# vLLM imports
from vllm import LLM, SamplingParams
from vllm.inputs import TokensPrompt
DEFAULT_TEMPERATURE = 0.0
TP = os.environ.get("TP", 2)
def load_model(checkpoint: str):
llm = LLM(
model=checkpoint,
tensor_parallel_size=TP, #... | --- +++ @@ -1,3 +1,7 @@+"""
+NOTE: this is not the most efficient way to use vLLM. It's a simple implementation that infers
+one token at a time to mimic the behavior of the Triton implementation.
+"""
import os
from typing import Callable, List, Optional
@@ -10,6 +14,10 @@ TP = os.environ.get("TP", 2)
def loa... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/responses_api/inference/vllm.py |
Add docstrings to existing functions | # Copyright 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | --- +++ @@ -11,6 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+"""
+Contains a resharding manager that binds weights from FSDP zero3 to XPerfGPT
+"""
from torch.distributed.... | https://raw.githubusercontent.com/verl-project/verl/HEAD/verl/workers/sharding_manager/fsdp_ulysses.py |
Help me comply with documentation standards | import contextvars
import dataclasses
import functools
import itertools
import json
import re
import textwrap
from typing import Any, AsyncIterator, Callable, ParamSpec, Sequence
from urllib.parse import quote, unquote
import pydantic
import structlog
import tiktoken
from aiohttp import ClientSession
from openai_harmo... | --- +++ @@ -94,6 +94,7 @@
@functools.cache
def max_chars_per_token(enc_name: str) -> int:
+ """Typical value is 128, but let's be safe."""
tok_lens = _tiktoken_vocabulary_lengths(enc_name)
return max(tok_lens)
@@ -142,6 +143,7 @@ def get_page_metadata(
curr_page: PageContents,
) -> dict[str, str... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/tools/simple_browser/simple_browser_tool.py |
Write docstrings for this repository |
import functools
import asyncio
import logging
import os
from abc import abstractmethod
from importlib.metadata import version
from typing import Callable, ParamSpec, TypeVar
from urllib.parse import quote
import chz
from aiohttp import ClientSession, ClientTimeout
from tenacity import (
after_log,
before_sle... | --- +++ @@ -1,3 +1,6 @@+"""
+Simple backend for the simple browser tool.
+"""
import functools
import asyncio
@@ -118,6 +121,7 @@
@chz.chz(typecheck=True)
class ExaBackend(Backend):
+ """Backend that uses the Exa Search API."""
source: str = chz.field(doc="Description of the backend source")
api_k... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/tools/simple_browser/backend.py |
Document all endpoints with docstrings | import json
import math
import os
import torch
from torch.profiler import record_function
from gpt_oss.torch.model import ModelConfig, RMSNorm
from gpt_oss.torch.weights import Checkpoint
from gpt_oss.triton.attention import attention, attention_ref
from gpt_oss.triton.moe import quantize_mx4, moe
class RotaryEmbed... | --- +++ @@ -37,6 +37,7 @@ self.cos, self.sin = self._compute_cos_sin(0, self.max_context_length)
def _compute_concentration_and_inv_freq(self) -> torch.Tensor:
+ """See YaRN paper: https://arxiv.org/abs/2309.00071"""
freq = self.base ** (
torch.arange(0, self.head_dim, 2, dty... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/triton/model.py |
Generate consistent documentation across files |
import json
import threading
import time
from typing import Callable, Optional
import requests
from openai_harmony import HarmonyEncodingName, load_harmony_encoding
EOS_TOKEN = 200002 # only used on hard timeout
# Tunables
POLL_INTERVAL_S = 0.01 # 10ms between buffer checks
CALL_MAX_WAIT_S = 0.250 # max time to ... | --- +++ @@ -1,3 +1,8 @@+"""
+NOTE: this is a stitched together implementation that uses Ollama for inference. It's primarily used
+for testing and development. It does not leverage any prompt caching or other optimizations and
+can therefore be slow between turns.
+"""
import json
import threading
@@ -114,6 +119,11... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/responses_api/inference/ollama.py |
Insert docstrings into my code |
from __future__ import annotations
import dataclasses
import functools
import logging
import re
from urllib.parse import urljoin, urlparse
import aiohttp
import html2text
import lxml
import lxml.etree
import lxml.html
import pydantic
import tiktoken
logger = logging.getLogger(__name__)
HTML_SUP_RE = re.compile(r... | --- +++ @@ -1,3 +1,6 @@+"""
+Page contents for the simple browser tool.
+"""
from __future__ import annotations
@@ -61,6 +64,7 @@
def get_domain(url: str) -> str:
+ """Extracts the domain from a URL."""
if "http" not in url:
# If `get_domain` is called on a domain, add a scheme so that the
... | https://raw.githubusercontent.com/openai/gpt-oss/HEAD/gpt_oss/tools/simple_browser/page_contents.py |
Auto-generate documentation strings for this file | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Implementation of a NADE (Neural Autoreressive Distribution Estimator)."""
from __future__ import absolute_import
from __future__ import division
@@ -24,10 +25,21 @@
def _safe_... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/common/nade.py |
Write docstrings that follow conventions | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -13,6 +13,7 @@ # limitations under the License.
# Forked from https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/utils/hparam.py pylint: disable=line-too-long
+"""Hyperparameter values."""
from __future__ import absolute_import
from __future__ import division
from __future__ import ... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/contrib/training.py |
Add well-formatted docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""A module for implementing interaction between MIDI and SequenceGenerators."""
import abc
import threading
@@ -24,6 +25,7 @@
def adjust_sequence_times(sequence, delta_time):
+ ... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/interfaces/midi/midi_interaction.py |
Write docstrings for backend logic | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,18 +12,53 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Tensorflow-related utilities."""
from magenta.contrib import training as contrib_training
import tensorflow.compat.v1 as tf
def merge_hparams(hparams_1, hparams_2):
+ """Me... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/common/tf_utils.py |
Create structured documentation for my script | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,10 +12,17 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Forked classes and functions from `tf.contrib.cudnn_rnn`."""
from magenta.contrib import rnn as contrib_rnn
class CudnnCompatibleLSTMCell(contrib_rnn.LSTMBlockCell):
+ """Cudn... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/contrib/cudnn_rnn.py |
Improve my code by adding docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Loss methods for real-time arbitrary image stylization model."""
from magenta.models.image_stylization import learning as learning_utils
from magenta.models.image_stylization import ... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/arbitrary_image_stylization/arbitrary_image_stylization_losses.py |
Generate descriptive docstrings automatically | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Beam search library."""
import collections
import copy
@@ -25,6 +26,26 @@
def _generate_branches(beam_entries, generate_step_fn, branch_factor,
num_steps)... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/common/beam_search.py |
Write docstrings for data processing functions | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Forked classes and functions from `tf.contrib.seq2seq`."""
import abc
import collections
@@ -28,6 +29,17 @@
def _transpose_batch_time(x):
+ """Transposes the batch and time di... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/contrib/seq2seq.py |
Add docstrings that explain purpose and usage | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,20 +12,57 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utility functions for working with nested state structures."""
import numpy as np
import tensorflow.compat.v1 as tf
def unbatch(batched_states, batch_size=1):
+ """Splits a... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/common/state_util.py |
Generate docstrings for each module | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utility functions for concurrency."""
import functools
import threading
@@ -19,6 +20,7 @@
def serialized(func):
+ """Decorator to provide mutual exclusion for method using _lo... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/common/concurrency.py |
Document this code for team use | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Forked classes and functions from `tf.contrib.rnn`."""
import tensorflow.compat.v1 as tf
import tf_slim
@@ -40,6 +41,20 @@
def assert_like_rnncell(cell_name, cell):
+ """Raise... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/contrib/rnn.py |
Generate docstrings for script automation | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""A MIDI interface to the sequence generators.
+
+Captures monophonic input MIDI sequences and plays back responses from the
+sequence generator.
+"""
import functools
import re
impo... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/interfaces/midi/magenta_midi.py |
Add docstrings for production code | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Methods for building arbitrary image stylization model with MobileNetV2."""
from magenta.models.arbitrary_image_stylization import arbitrary_image_stylization_losses as losses
from m... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/arbitrary_image_stylization/arbitrary_image_stylization_build_mobilenet_model.py |
Add well-formatted docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Drums RNN generation code as a SequenceGenerator interface."""
import functools
@@ -22,9 +23,22 @@
class DrumsRnnSequenceGenerator(sequence_generator.BaseSequenceGenerator):
+... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/drums_rnn/drums_rnn_sequence_generator.py |
Add docstrings to improve readability | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Methods for building real-time arbitrary image stylization model."""
from magenta.models.arbitrary_image_stylization import arbitrary_image_stylization_losses as losses
from magent... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/arbitrary_image_stylization/arbitrary_image_stylization_build_model.py |
Add docstrings for better understanding | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Drums RNN model."""
from magenta.contrib import training as contrib_training
from magenta.models.shared import events_rnn_model
@@ -20,13 +21,41 @@
class DrumsRnnModel(events_r... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/drums_rnn/drums_rnn_model.py |
Write docstrings for utility functions | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""A module for interfacing with the MIDI environment."""
# TODO(adarob): Use flattened imports.
@@ -50,18 +51,55 @@
class MidiHubError(Exception): # pylint:disable=g-bad-except... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/interfaces/midi/midi_hub.py |
Help me write clear docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Generate drum tracks from a trained checkpoint of a drums RNN model.
+
+Uses flags to define operation.
+"""
import ast
import os
import time
@@ -96,6 +100,7 @@
def get_checkpo... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/drums_rnn/drums_rnn_generate.py |
Write clean docstrings for readability | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Pipeline to create DrumsRNN dataset."""
from magenta.pipelines import dag_pipeline
from magenta.pipelines import drum_pipelines
@@ -22,6 +23,15 @@
def get_pipeline(config, eval... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/drums_rnn/drums_rnn_pipeline.py |
Document this script properly | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Provides a class, defaults, and utils for Drums RNN model configuration."""
from magenta.models.drums_rnn import drums_rnn_model
import tensorflow.compat.v1 as tf
@@ -41,6 +42,14 @... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/drums_rnn/drums_rnn_config_flags.py |
Add docstrings that explain inputs and outputs | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,26 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Genarates a TF-Hub module for arbitrary image stylization.
+
+The module is compatible with TF-2 and is intended as a demonstration of TF-Hub
+module creation based on TF-1 models.
+
... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/arbitrary_image_stylization/export_hub.py |
Generate documentation strings for clarity | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Style transfer network code.
+
+This model does not apply styles in the encoding
+layers. Encoding layers (contract) use batch norm as the normalization function.
+"""
from magenta.m... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/arbitrary_image_stylization/nza_model.py |
Add concise docstrings to each method | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Data utility."""
from __future__ import absolute_import
from __future__ import division
@@ -24,6 +25,7 @@
class DataHelper(object):
+ """A class for querying and converting da... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/data_helpers.py |
Write Python docstrings for this snippet | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Script to evaluate a dataset fold under a model."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -94,6 +95,7 @@
... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/coconet_evaluate.py |
Help me comply with documentation standards | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Flags utility object for handling hyperparameter state."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -21,6 +22,... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/flags.py |
Write docstrings including parameters and return values | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Train the model."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -128,6 +129,7 @@
def estimate_popstats(unused... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/coconet_train.py |
Add docstrings to make code maintainable | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""GANSynth Model class definition.
+
+Exposes external API for generating samples and evaluation.
+"""
import json
import os
@@ -29,6 +33,7 @@
def set_flags(flags):
+ """Set de... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/model.py |
Add docstrings to incomplete code | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,17 +12,39 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Layers for a progressive GAN model.
+
+This module contains basic building blocks to build a progressive GAN model.
+
+See https://arxiv.org/abs/1710.10196 for details about the mode... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/layers.py |
Add concise docstrings to each method | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Helpers for evaluating the log likelihood of pianorolls under a model."""
import time
from magenta.models.coconet import lib_tfutil
@@ -22,6 +23,22 @@
def evaluate(evaluator, p... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_evaluation.py |
Document this script properly | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Convert trained mobile arbitrary style transfer model to TF Lite."""
from __future__ import absolute_import
from __future__ import division
@@ -44,6 +45,12 @@
def load_checkpoi... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/arbitrary_image_stylization/arbitrary_image_stylization_convert_tflite.py |
Add docstrings to clarify complex logic | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Generate from trained model from scratch or condition on a partial score."""
import itertools as it
import os
import re
@@ -115,8 +116,15 @@
class Generator(object):
+ """Insta... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/coconet_sample.py |
Write docstrings including parameters and return values | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Data normalizer."""
import io
import os
@@ -31,6 +32,7 @@
class DataNormalizer(object):
+ """A class to normalize data."""
def __init__(self, config, file_name):
sel... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/data_normalizer.py |
Create structured documentation for my script | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Module contains a registry of dataset classes."""
from __future__ import absolute_import
from __future__ import division
@@ -27,20 +28,25 @@
class BaseDataset(object):
+ """A ... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/datasets.py |
Generate docstrings with parameter types | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Evaluates the N-styles style transfer model."""
import ast
import os
@@ -83,6 +84,7 @@ labels = tf.unstack(labels)
def _create_normalizer_params(style_label):
+ """... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/image_stylization_evaluate.py |
Write docstrings describing functionality | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utilities for structured logging of intermediate values during sampling."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_funct... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_logging.py |
Generate docstrings for this script | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Image-related functions for style transfer."""
import io
import os
import tempfile
@@ -27,6 +28,29 @@
def imagenet_inputs(batch_size, image_size, num_readers=1,
... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/image_utils.py |
Generate docstrings with examples | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Tools for masking out pianorolls in different ways, such as by instrument."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_fun... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_mask.py |
Add professional docstrings to my codebase | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utilities for converting between NoteSequences and pianorolls."""
import numpy as np
import pretty_midi
import tensorflow.compat.v1 as tf
class PitchOutOfEncodeRangeError(Exc... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_pianoroll.py |
Generate NumPy-style docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utility for exporting and loading a Coconet SavedModel."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -20,6 +21,... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_saved_model.py |
Write docstrings for algorithm functions | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Helper functions for generating sounds.
+"""
from magenta.models.gansynth.lib import util
import note_seq
@@ -23,6 +25,7 @@
def slerp(p0, p1, t):
+ """Spherical linear interpo... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/generate_util.py |
Write docstrings for backend logic | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Generates a stylized image given an unstylized image."""
import ast
import os
@@ -41,6 +42,7 @@
def _load_checkpoint(sess, checkpoint):
+ """Loads a checkpoint file into the s... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/image_stylization_transform.py |
Generate documentation strings for clarity | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Classes and subroutines for generating pianorolls from coconet."""
from magenta.models.coconet import lib_data
from magenta.models.coconet import lib_logging
@@ -27,8 +28,20 @@
... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_sampling.py |
Generate documentation strings for clarity | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Classes for datasets and batches."""
import os
from magenta.models.coconet import lib_mask
@@ -22,8 +23,20 @@
class Dataset(lib_util.Factory):
+ """Class for retrieving differ... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_data.py |
Annotate my code with docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Provides a class, defaults, and utils for improv RNN model configuration."""
from magenta.models.improv_rnn import improv_rnn_model
import tensorflow.compat.v1 as tf
@@ -42,6 +43,1... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/improv_rnn/improv_rnn_config_flags.py |
Document functions with clear intent | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Generate melodies from a trained checkpoint of an improv RNN model."""
from __future__ import absolute_import
from __future__ import division
@@ -111,6 +112,7 @@
def get_checkp... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/improv_rnn/improv_rnn_generate.py |
Generate docstrings for script automation | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Melody-over-chords RNN generation code as a SequenceGenerator interface."""
import functools
@@ -23,9 +24,22 @@
class ImprovRnnSequenceGenerator(sequence_generator.BaseSequenc... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/improv_rnn/improv_rnn_sequence_generator.py |
Add missing documentation to my Python functions | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Defines the graph for sampling from Coconet."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -27,8 +28,19 @@
c... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_tfsampling.py |
Write Python docstrings for this snippet | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Defines the graph for a convolutional net designed for music autofill."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_functio... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_graph.py |
Add documentation for all methods | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utilities for context managing, data prep and sampling such as softmax."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_functi... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_util.py |
Write Python docstrings for this snippet | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utilities that depend on Tensorflow."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -22,12 +23,21 @@
# adapts b... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_tfutil.py |
Expand my code with proper documentation strings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Classes for defining hypermaters and model architectures."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
@@ -27,6 +2... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/coconet/lib_hparams.py |
Add docstrings to my Python code | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Generator and discriminator functions.
+"""
from __future__ import absolute_import
from __future__ import division
@@ -24,11 +26,13 @@
def _num_filters_fn(block_id, **kwargs):
... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/network_functions.py |
Add professional docstrings to my codebase | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,13 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Generator and discriminator for a progressive GAN model.
+
+See https://arxiv.org/abs/1710.10196 for details about the model.
+
+See https://github.com/tkarras/progressive_growing_of_... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/networks.py |
Add docstrings to improve code quality | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Useful functions."""
import io
import os
@@ -27,6 +28,7 @@
def one_hot_to_embedding(one_hot, embedding_size=None):
+ """Gets a dense embedding vector from a one-hot encoding."... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/util.py |
Add docstrings to improve code quality | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Learning-related functions for style transfer."""
from magenta.models.image_stylization import vgg
import numpy as np
import tensorflow.compat.v1 as tf
@@ -19,6 +20,16 @@
def pr... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/learning.py |
Generate docstrings with parameter types | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,33 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Common functions/helpers for the joint model.
+
+This library contains many comman functions and helpers used to train (using
+script `train_joint.py`) the joint model (defined in `mo... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/latent_transfer/common_joint.py |
Write Python docstrings for this snippet | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -13,6 +13,16 @@ # limitations under the License.
# ==============================================================================
+"""Small library that points to the ImageNet data set.
+
+Methods of ImagenetData class:
+ data_files: Returns a python list of all (sharded) data set files.
+ num_examples_... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/imagenet_data.py |
Create Google-style docstrings for my code | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Convert trained mobile style transfer model to TF Lite."""
import os
import tempfile
@@ -36,6 +37,7 @@
def _load_checkpoint(sess, checkpoint):
+ """Loads a checkpoint file int... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/image_stylization_convert_tflite.py |
Add missing documentation to my Python functions | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Style transfer network code."""
from magenta.models.image_stylization import ops
import tensorflow.compat.v1 as tf
import tf_slim as slim
@@ -22,6 +23,22 @@ normalizer... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/model.py |
Add professional docstrings to my codebase | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Helper object for transforming audio to spectra.
+
+Handles transformations between waveforms, stfts, spectrograms,
+mel-spectrograms, and instantaneous frequency (specgram).
+"""
... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/specgrams_helper.py |
Add detailed documentation for each class | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Encode the data using pre-trained VAE on dataspace.
+
+This script encodes the instances in dataspace (x) from the training set into
+distributions in the latent space (z) using the p... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/latent_transfer/encode_dataspace.py |
Document this code for team use | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""The joint transfer model that bridges latent spaces of dataspace models.
+
+The whole experiment handles transfer between latent space
+of generative models that model the data. This ... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/latent_transfer/model_joint.py |
Add docstrings to make code maintainable | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Implementation of the VGG-16 network.
+
+In this specific implementation, max-pooling operations are replaced with
+average-pooling operations.
+"""
import os
import tensorflow.co... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/vgg.py |
Write beginner-friendly docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Library of spectral processing functions.
+
+Includes transforming linear to mel frequency scales and phase to instantaneous
+frequency.
+"""
from __future__ import absolute_import... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/spectral_ops.py |
Generate docstrings for each module | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Compound TensorFlow operations for style transfer."""
import tensorflow.compat.v1 as tf
import tf_slim as slim
@@ -28,6 +29,39 @@ outputs_collections=... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/ops.py |
Create documentation strings for testing functions | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,13 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Train a progressive GAN model.
+
+See https://arxiv.org/abs/1710.10196 for details about the model.
+
+See https://github.com/tkarras/progressive_growing_of_gans for the original
+the... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/gansynth/lib/train_util.py |
Document all public functions with docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,13 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Creates a dataset out of a list of style images.
+
+Each style example in the dataset contains the style image as a JPEG string, a
+unique style label and the pre-computed Gram matric... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/image_stylization/image_stylization_create_dataset.py |
Add docstrings to improve collaboration | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Pipeline to create ImprovRNN dataset."""
from magenta.pipelines import dag_pipeline
from magenta.pipelines import lead_sheet_pipelines
@@ -24,8 +25,16 @@
class EncoderPipeline(... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/improv_rnn/improv_rnn_pipeline.py |
Add detailed documentation for each class | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,26 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Common functions/helpers for dataspace model.
+
+This library contains many common functions and helpers used to for the
+dataspace model (defined in `train_dataspace.py`) that is use... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/latent_transfer/common.py |
Provide clean and structured docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Melody RNN model."""
import copy
@@ -26,9 +27,31 @@
class ImprovRnnModel(events_rnn_model.EventSequenceRnnModel):
+ """Class for RNN melody-given-chords generation models."""... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/improv_rnn/improv_rnn_model.py |
Create Google-style docstrings for my code | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Generate melodies from a trained checkpoint of a melody RNN model."""
import ast
import os
import time
@@ -95,6 +96,7 @@
def get_checkpoint():
+ """Get the training dir or chec... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/melody_rnn/melody_rnn_generate.py |
Provide clean and structured docstrings | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Base Music Variational Autoencoder (MusicVAE) model."""
import abc
from magenta.contrib import training as contrib_training
@@ -23,44 +24,129 @@
class BaseEncoder(object, metac... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/music_vae/base_model.py |
Generate documentation strings for clarity | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Autoencoder config.
+
+All configs should have encode() and decode().
+"""
from magenta.models.nsynth import utils
import tensorflow.compat.v1 as tf
@@ -26,6 +30,19 @@
def enc... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/nsynth/baseline/models/ae_configs/nfft_1024.py |
Generate helpful docstrings for debugging | # Copyright 2025 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""MusicVAE LSTM model utilities."""
import collections
from magenta.contrib import rnn as contrib_rnn
@@ -22,6 +23,7 @@
def rnn_cell(rnn_cell_size, dropout_keep_prob, residual, i... | https://raw.githubusercontent.com/magenta/magenta/HEAD/magenta/models/music_vae/lstm_utils.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.