

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Elaborazione di dati con processori Framework
<a name="processing-job-frameworks"></a>

A `FrameworkProcessor` può eseguire processi di elaborazione con un framework di machine learning specifico, fornendoti un contenitore SageMaker gestito da Amazon AI per qualsiasi framework di apprendimento automatico tu scelga. `FrameworkProcessor`fornisce contenitori predefiniti per i seguenti framework di apprendimento automatico: Hugging Face,,, e. MXNet PyTorch TensorFlow XGBoost

La classe `FrameworkProcessor` fornisce anche la personalizzazione della configurazione del container. La classe `FrameworkProcessor` supporta la specificazione di una directory di origine `source_dir` per gli script di elaborazione e le dipendenze. Con questa funzionalità, è possibile concedere al processore l'accesso a più script in una directory invece di specificare un solo script. `FrameworkProcessor` supporta anche l'inclusione di un file `requirements.txt` nella `source_dir` per personalizzare le librerie Python da installare nel container.

Per ulteriori informazioni sulla `FrameworkProcessor` classe e sui relativi metodi e parametri, consulta [FrameworkProcessor](https://sagemaker.readthedocs.io/en/stable/api/training/processing.html#sagemaker.processing.FrameworkProcessor)l'SDK *Amazon SageMaker AI Python*.

Per vedere esempi di utilizzo di un `FrameworkProcessor` per ciascuno dei framework di machine learning supportati, consulta i seguenti argomenti.

**Topics**
+ [Esempio di codice utilizzato HuggingFaceProcessor nell'SDK Amazon SageMaker Python](processing-job-frameworks-hugging-face.md)
+ [MXNet Processore Framework](processing-job-frameworks-mxnet.md)
+ [PyTorch Processore Framework](processing-job-frameworks-pytorch.md)
+ [TensorFlow Processore Framework](processing-job-frameworks-tensorflow.md)
+ [XGBoost Processore Framework](processing-job-frameworks-xgboost.md)

# Esempio di codice utilizzato HuggingFaceProcessor nell'SDK Amazon SageMaker Python
<a name="processing-job-frameworks-hugging-face"></a>

Hugging Face è un fornitore open source di modelli di elaborazione del linguaggio naturale (NLP). L'`HuggingFaceProcessor`SDK di Amazon SageMaker Python ti offre la possibilità di eseguire processi di elaborazione con gli script Hugging Face. Quando utilizzi `HuggingFaceProcessor`, puoi sfruttare un container Docker creato da Amazon con un ambiente Hugging Face gestito in modo da non dover portare il tuo container.

Il seguente esempio di codice mostra come utilizzare il `HuggingFaceProcessor` per eseguire il processo di elaborazione utilizzando un'immagine Docker fornita e gestita da AI. SageMaker Nota che quando esegui il job, puoi specificare una directory contenente gli script e le dipendenze nell'`source_dir`argomento e puoi avere un `requirements.txt` file all'interno della tua `source_dir` directory che specifica le dipendenze per i tuoi script di elaborazione. SageMaker L'elaborazione installa automaticamente le dipendenze presenti nel `requirements.txt` contenitore.

```
from sagemaker.huggingface import HuggingFaceProcessor
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker import get_execution_role

#Initialize the HuggingFaceProcessor
hfp = HuggingFaceProcessor(
    role=get_execution_role(), 
    instance_count=1,
    instance_type='ml.g4dn.xlarge',
    transformers_version='4.4.2',
    pytorch_version='1.6.0', 
    base_job_name='frameworkprocessor-hf'
)

#Run the processing job
hfp.run(
    code='processing-script.py',
    source_dir='scripts',
    inputs=[
        ProcessingInput(
            input_name='data',
            source=f's3://{BUCKET}/{S3_INPUT_PATH}',
            destination='/opt/ml/processing/input/data/'
        )
    ],
    outputs=[
        ProcessingOutput(output_name='train', source='/opt/ml/processing/output/train/', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'),
        ProcessingOutput(output_name='test', source='/opt/ml/processing/output/test/', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'),
        ProcessingOutput(output_name='val', source='/opt/ml/processing/output/val/', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}')
    ]
)
```

Se hai un file `requirements.txt`, dovrebbe essere un elenco di librerie che desideri installare nel container. Il percorso per `source_dir` può essere un percorso URI relativo, assoluto o Amazon S3. Tuttavia, se utilizzi un URI Amazon S3, deve puntare a un file tar.gz. Puoi avere più script nella directory specificata per `source_dir`. Per ulteriori informazioni sulla `HuggingFaceProcessor` classe, consulta [Hugging Face Estimator](https://sagemaker.readthedocs.io/en/stable/frameworks/huggingface/sagemaker.huggingface.html) nell'SDK *Amazon SageMaker * AI Python.

# MXNet Processore Framework
<a name="processing-job-frameworks-mxnet"></a>

Apache MXNet è un framework di deep learning open source comunemente usato per l'addestramento e la distribuzione di reti neurali. L'`MXNetProcessor`SDK Amazon SageMaker Python ti offre la possibilità di eseguire processi di elaborazione con script. MXNet Quando usi il`MXNetProcessor`, puoi sfruttare un contenitore Docker creato da Amazon con un MXNet ambiente gestito in modo da non dover portare il tuo contenitore.

Il seguente esempio di codice mostra come utilizzare il `MXNetProcessor` per eseguire il processo di elaborazione utilizzando un'immagine Docker fornita e gestita da AI. SageMaker Nota che quando esegui il job, puoi specificare una directory contenente gli script e le dipendenze nell'`source_dir`argomento e puoi avere un `requirements.txt` file all'interno della tua `source_dir` directory che specifica le dipendenze per i tuoi script di elaborazione. SageMaker L'elaborazione installa automaticamente le dipendenze presenti nel `requirements.txt` contenitore.

```
from sagemaker.mxnet import MXNetProcessor
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker import get_execution_role

#Initialize the MXNetProcessor
mxp = MXNetProcessor(
    framework_version='1.8.0',
    py_version='py37',
    role=get_execution_role(), 
    instance_count=1,
    instance_type='ml.c5.xlarge',
    base_job_name='frameworkprocessor-mxnet'
)

#Run the processing job
mxp.run(
    code='processing-script.py',
    source_dir='scripts',
    inputs=[
        ProcessingInput(
            input_name='data',
            source=f's3://{BUCKET}/{S3_INPUT_PATH}',
            destination='/opt/ml/processing/input/data/'
        )
    ],
    outputs=[
        ProcessingOutput(
            output_name='processed_data',
            source='/opt/ml/processing/output/',
            destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'
        )
    ]
)
```

Se hai un file `requirements.txt`, dovrebbe essere un elenco di librerie che desideri installare nel container. Il percorso per `source_dir` può essere un percorso URI relativo, assoluto o Amazon S3. Tuttavia, se utilizzi un URI Amazon S3, deve puntare a un file tar.gz. Puoi avere più script nella directory specificata per `source_dir`. Per ulteriori informazioni sulla `MXNetProcessor` classe, consulta [MXNet Estimator](https://sagemaker.readthedocs.io/en/stable/frameworks/mxnet/sagemaker.mxnet.html#mxnet-estimator) nell'SDK *Amazon SageMaker Python*.

# PyTorch Processore Framework
<a name="processing-job-frameworks-pytorch"></a>

PyTorch è un framework di machine learning open source. L'`PyTorchProcessor`SDK Amazon SageMaker Python ti offre la possibilità di eseguire processi di elaborazione con script. PyTorch Quando usi il`PyTorchProcessor`, puoi sfruttare un contenitore Docker creato da Amazon con un PyTorch ambiente gestito in modo da non dover portare il tuo contenitore.

Il seguente esempio di codice mostra come utilizzare il `PyTorchProcessor` per eseguire il processo di elaborazione utilizzando un'immagine Docker fornita e gestita da AI. SageMaker Nota che quando esegui il job, puoi specificare una directory contenente gli script e le dipendenze nell'`source_dir`argomento e puoi avere un `requirements.txt` file all'interno della tua `source_dir` directory che specifica le dipendenze per i tuoi script di elaborazione. SageMaker L'elaborazione installa automaticamente le dipendenze presenti nel `requirements.txt` contenitore.

Per le PyTorch versioni supportate dall' SageMaker intelligenza artificiale, guarda le immagini disponibili del [Deep Learning Container](https://github.com/aws/deep-learning-containers/blob/master/available_images.md).

```
from sagemaker.pytorch.processing import PyTorchProcessor
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker import get_execution_role

#Initialize the PyTorchProcessor
pytorch_processor = PyTorchProcessor(
    framework_version='1.8',
    role=get_execution_role(),
    instance_type='ml.m5.xlarge',
    instance_count=1,
    base_job_name='frameworkprocessor-PT'
)

#Run the processing job
pytorch_processor.run(
    code='processing-script.py',
    source_dir='scripts',
    inputs=[
        ProcessingInput(
            input_name='data',
            source=f's3://{BUCKET}/{S3_INPUT_PATH}',
            destination='/opt/ml/processing/input'
        )
    ],
    outputs=[
        ProcessingOutput(output_name='data_structured', source='/opt/ml/processing/tmp/data_structured', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'),
        ProcessingOutput(output_name='train', source='/opt/ml/processing/output/train', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'),
        ProcessingOutput(output_name='validation', source='/opt/ml/processing/output/val', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'),
        ProcessingOutput(output_name='test', source='/opt/ml/processing/output/test', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'),
        ProcessingOutput(output_name='logs', source='/opt/ml/processing/logs', destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}')
    ]
)
```

Se hai un file `requirements.txt`, dovrebbe essere un elenco di librerie che desideri installare nel container. Il percorso per `source_dir` può essere un percorso URI relativo, assoluto o Amazon S3. Tuttavia, se utilizzi un URI Amazon S3, deve puntare a un file tar.gz. Puoi avere più script nella directory specificata per `source_dir`. Per ulteriori informazioni sulla `PyTorchProcessor` classe, consulta [PyTorch Estimator](https://sagemaker.readthedocs.io/en/stable/frameworks/pytorch/sagemaker.pytorch.html) nell'SDK *Amazon SageMaker Python*.

# TensorFlow Processore Framework
<a name="processing-job-frameworks-tensorflow"></a>

TensorFlow è una libreria open source per l'apprendimento automatico e l'intelligenza artificiale. L'`TensorFlowProcessor`SDK Amazon SageMaker Python ti offre la possibilità di eseguire processi di elaborazione con script. TensorFlow Quando usi il`TensorFlowProcessor`, puoi sfruttare un contenitore Docker creato da Amazon con un TensorFlow ambiente gestito in modo da non dover portare il tuo contenitore.

Il seguente esempio di codice mostra come utilizzare il `TensorFlowProcessor` per eseguire il processo di elaborazione utilizzando un'immagine Docker fornita e gestita da AI. SageMaker Nota che quando esegui il job, puoi specificare una directory contenente gli script e le dipendenze nell'`source_dir`argomento e puoi avere un `requirements.txt` file all'interno della tua `source_dir` directory che specifica le dipendenze per i tuoi script di elaborazione. SageMaker L'elaborazione installa automaticamente le dipendenze presenti nel `requirements.txt` contenitore.

```
from sagemaker.tensorflow import TensorFlowProcessor
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker import get_execution_role

#Initialize the TensorFlowProcessor
tp = TensorFlowProcessor(
    framework_version='2.3',
    role=get_execution_role(),
    instance_type='ml.m5.xlarge',
    instance_count=1,
    base_job_name='frameworkprocessor-TF',
    py_version='py37'
)

#Run the processing job
tp.run(
    code='processing-script.py',
    source_dir='scripts',
    inputs=[
        ProcessingInput(
            input_name='data',
            source=f's3://{BUCKET}/{S3_INPUT_PATH}',
            destination='/opt/ml/processing/input/data'
        ),
        ProcessingInput(
            input_name='model',
            source=f's3://{BUCKET}/{S3_PATH_TO_MODEL}',
            destination='/opt/ml/processing/input/model'
        )
    ],
    outputs=[
        ProcessingOutput(
            output_name='predictions',
            source='/opt/ml/processing/output',
            destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'
        )
    ]
)
```

Se hai un file `requirements.txt`, dovrebbe essere un elenco di librerie che desideri installare nel container. Il percorso per `source_dir` può essere un percorso URI relativo, assoluto o Amazon S3. Tuttavia, se utilizzi un URI Amazon S3, deve puntare a un file tar.gz. Puoi avere più script nella directory specificata per `source_dir`. Per ulteriori informazioni sulla `TensorFlowProcessor` classe, consulta [TensorFlow Estimator](https://sagemaker.readthedocs.io/en/stable/frameworks/tensorflow/sagemaker.tensorflow.html#tensorflow-estimator) nell'SDK *Amazon SageMaker Python*.

# XGBoost Processore Framework
<a name="processing-job-frameworks-xgboost"></a>

XGBoost è un framework di machine learning open source. L'`XGBoostProcessor`SDK Amazon SageMaker Python ti offre la possibilità di eseguire processi di elaborazione con script. XGBoost Quando utilizzi il XGBoost Processore, puoi sfruttare un contenitore Docker creato da Amazon con un XGBoost ambiente gestito in modo da non dover portare il tuo contenitore.

Il seguente esempio di codice mostra come utilizzare il `XGBoostProcessor` per eseguire il processo di elaborazione utilizzando un'immagine Docker fornita e gestita da AI. SageMaker Nota che quando esegui il job, puoi specificare una directory contenente gli script e le dipendenze nell'`source_dir`argomento e puoi avere un `requirements.txt` file all'interno della tua `source_dir` directory che specifica le dipendenze per i tuoi script di elaborazione. SageMaker L'elaborazione installa automaticamente le dipendenze presenti nel `requirements.txt` contenitore.

```
from sagemaker.xgboost import XGBoostProcessor
from sagemaker.processing import ProcessingInput, ProcessingOutput
from sagemaker import get_execution_role

#Initialize the XGBoostProcessor
xgb = XGBoostProcessor(
    framework_version='1.2-2',
    role=get_execution_role(),
    instance_type='ml.m5.xlarge',
    instance_count=1,
    base_job_name='frameworkprocessor-XGB',
)

#Run the processing job
xgb.run(
    code='processing-script.py',
    source_dir='scripts',
    inputs=[
        ProcessingInput(
            input_name='data',
            source=f's3://{BUCKET}/{S3_INPUT_PATH}',
            destination='/opt/ml/processing/input/data'
        )
    ],
    outputs=[
        ProcessingOutput(
            output_name='processed_data',
            source='/opt/ml/processing/output/',
            destination=f's3://{BUCKET}/{S3_OUTPUT_PATH}'
        )
    ]
)
```

Se hai un file `requirements.txt`, dovrebbe essere un elenco di librerie che desideri installare nel container. Il percorso per `source_dir` può essere un percorso URI relativo, assoluto o Amazon S3. Tuttavia, se utilizzi un URI Amazon S3, deve puntare a un file tar.gz. Puoi avere più script nella directory specificata per `source_dir`. Per ulteriori informazioni sulla `XGBoostProcessor` classe, consulta [XGBoost Estimator](https://sagemaker.readthedocs.io/en/stable/frameworks/xgboost/xgboost.html) nell'SDK *Amazon SageMaker Python*.