model-building
Select and construct DLTK 0.2.1 TensorFlow 1.x 3D networks and core model-building blocks from explicit rank-5 tensor contracts.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- model-building
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Select and construct DLTK 0.2.1 TensorFlow 1.x 3D networks and core model-building blocks from explicit rank-5 tensor contracts.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md8.5 KB
- 参考文档references/model-overview.md8.8 KB
- 参考文档references/troubleshooting.md7.1 KB
- 脚本scripts/network_smoke.py9.6 KB
03 SKILL.md 正文
DLTK model building
Use this route when the task is to choose or instantiate a DLTK network, residual unit, activation, loss, metric, or 3D upsampling layer. This is an operating guide for the public DLTK 0.2.1 API; it assumes Python 3.7 with TensorFlow 1.15.0 and graph-mode APIs such as tf.Session, tf.layers, tf.contrib, and tf.estimator. Keep these legacy API calls unchanged unless a separate migration task is explicitly requested.
Route the request
- Classification or scalar regression:
dltk.networks.regression_classification.resnet.resnet_3d. - Dense multi-class segmentation:
residual_unet_3d,asymmetric_residual_unet_3d, orresidual_fcn_3dfromdltk.networks.segmentation; choose UNet for concatenated skip features, asymmetric UNet for one decoder residual unit per scale, and FCN for additive upscore skips. - Multi-scale segmentation experiment:
deepmedic_3d, only with an explicit WIP acceptance; this implementation warns that it is not accuracy-equivalent to the original DeepMedic and uses linear/bilinear-style upsampling rather than the original repeat upsampling. - Representation learning/reconstruction:
convolutional_autoencoder_3d. - GAN graph:
dcgan_generator_3danddcgan_discriminator_3d; the network functions only construct the generator/discriminator dictionaries, not a complete training loop. - Resolution increase:
simple_super_resolution_3d; its transpose-convolution output is only meaningful when the input is an intentionally downsampled low-resolution view of a target, not as evidence that arbitrary full-resolution data can be recovered. - Reusable blocks:
vanilla_residual_unit_3d,linear_upsample_3d,get_linear_upsampling_kernel,prelu,leaky_relu,dice_loss,sparse_balanced_crossentropy, and NumPy metrics. See api-reference.md and model-overview.md.
Construct safely
- Confirm a TensorFlow 1.x graph and a static rank-5 input
[batch, x, y, z, channels]. Network functions assert rank 5; channel count must be statically known for residual padding/conversion, flattening, and transpose-convolution output shapes. - Set
num_classes,filters, andstridesdeliberately. For ResNet, UNet, FCN, autoencoder, and both GAN functions,len(filters)must equallen(strides). Each spatial stride is a 3-tuple. For a tiny graph, use all-one strides first; non-unit strides must leave compatible encoder/decoder spatial sizes and provide enough input extent for the chosen convolution/padding. - Pass
mode=modefrom the surrounding Estimatormodel_fn. Batch normalization usestraining=(mode == tf.estimator.ModeKeys.TRAIN);TRAINtherefore requires the caller to runtf.GraphKeys.UPDATE_OPSunder control dependencies. The network itself does not create the optimizer orEstimatorSpec. - Treat the returned dictionary as the public handoff. Segmentation and ResNet return
logits,y_prob, andy_; the autoencoder and super-resolution networks returnhidden_units/x_; the GAN generator returnsgen, while the discriminator returnslogits,probs, andpred. Preserve these keys when wiring prediction/export code. - For a real training workflow, hand feature/label shape and Reader concerns to data-pipelines, and hand Estimator loss/optimizer/update-op/export orchestration to training-and-estimators. Do not put file I/O or training loops in this route.
- Run the bounded graph-only check when TensorFlow 1.15.0 is available:
python scripts/network_smoke.py --family allfrom themodel-building/sub-skill directory The check creates tiny graphs and executes one forward pass; it never downloads data, trains, exports, or writes checkpoints.--helpis safe in any working directory.
Loss and metric choices
dice_loss(logits, labels, num_classes, smooth=1e-5, include_background=True, only_present=False)applies softmax internally and reduces Dice over batch/class spatial axes[1, 2, 3]; labels are sparse integer maps.only_present=Trueremoves absent classes, andinclude_background=Falseremoves class zero. It returns1 - mean(Dice), not a per-class vector.sparse_balanced_crossentropy(logits, labels)expects sparse labels and inverse-frequency weights from the labels in the current tensor. A class absent from that tensor receives a stabilized weight; inspect batch composition before interpreting the value.dltk.core.metrics.dice,abs_vol_difference, andcrossentropyare NumPy metrics.dicereturns one value per class and may produceNaNfor an absent class because its denominator is zero;crossentropytakes one-hot labels and interprets its first argument as logits unlesslogits=False.
Guardrails
- A rank-4 image or a missing channel dimension is not a valid network input. Fix the Reader/example shape to
[B, X, Y, Z, C]; do not reshape labels into a fake channel merely to bypass an assertion. - A
len(filters) != len(strides)error means the architecture schedule is malformed. A concat/add shape error means cumulative encoder strides, input spatial dimensions, or skip branch sizes do not match; first use all-one strides, then introduce one spatial factor at a time. dcgan_discriminator_3dcomparesx > 0.5on its logit tensor forpred; this is the package behavior, not a calibrated probability threshold. Useprobsonly when sigmoid probabilities are intended.deepmedic_3dis explicitly WIP and should not be presented as a reproduction of the original model or accuracy. Keep it out of routine smoke checks unless a task supplies compatible crop/pathway shapes.simple_super_resolution_3dperforms learned transpose-convolution upsampling; the application workflow obtains a low-resolution input by artificial downsampling. It does not establish recovery of information absent from a genuinely low-resolution measurement.
For owned shape, mode, batch-normalization, output-key, and legacy-runtime failures, use troubleshooting.md. For complete verified signatures and family details, use api-reference.md and model-overview.md.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).