Skip to main content

Neuraxle-TensorFlow

TensorFlow steps, savers, and utilities for Neuraxle.

Neuraxle is a Machine Learning (ML) library for building neat pipelines, providing the right abstractions to both ease research, development, and deployment of your ML applications.

Usage example

See also a complete example

Tensorflow 1

Create a tensorflow 1 model step by giving it a graph, an optimizer, and a loss function.

def create_graph(step: TensorflowV1ModelStep, context: ExecutionContext):
    tf.placeholder('float', name='data_inputs')
    tf.placeholder('float', name='expected_outputs')

    tf.Variable(np.random.rand(), name='weight')
    tf.Variable(np.random.rand(), name='bias')
    
    return tf.add(tf.multiply(step['data_inputs'], step['weight']), step['bias'])
    
"""
# Note: you can also return a tuple containing two elements : tensor for training (fit), tensor for inference (transform)
def create_graph(step: TensorflowV1ModelStep, context: ExecutionContext)
    # ...
    decoder_outputs_training = create_training_decoder(step, encoder_state, decoder_cell)
    decoder_outputs_inference = create_inference_decoder(step, encoder_state, decoder_cell)

    return decoder_outputs_training, decoder_outputs_inference
"""


def create_loss(step: TensorflowV1ModelStep, context: ExecutionContext):
    return tf.reduce_sum(tf.pow(step['output'] - step['expected_outputs'], 2)) / (2 * N_SAMPLES)

def create_optimizer(step: TensorflowV1ModelStep, context: ExecutionContext):
    return tf.train.GradientDescentOptimizer(step.hyperparams['learning_rate'])

model_step = TensorflowV1ModelStep(
    create_grah=create_graph,
    create_loss=create_loss,
    create_optimizer=create_optimizer,
    has_expected_outputs=True
).set_hyperparams(HyperparameterSamples({
    'learning_rate': 0.01
})).set_hyperparams_space(HyperparameterSpace({
    'learning_rate': LogUniform(0.0001, 0.01)
}))

Tensorflow 2

Create a tensorflow 2 model step by giving it a model, an optimizer, and a loss function.

def create_model(step: Tensorflow2ModelStep, context: ExecutionContext):
    return LinearModel()

def create_optimizer(step: Tensorflow2ModelStep, context: ExecutionContext):
    return tf.keras.optimizers.Adam(0.1)

def create_loss(step: Tensorflow2ModelStep, expected_outputs, predicted_outputs):
    return tf.reduce_mean(tf.abs(predicted_outputs - expected_outputs))

model_step = Tensorflow2ModelStep(
    create_model=create_model,
    create_optimizer=create_optimizer,
    create_loss=create_loss,
    tf_model_checkpoint_folder=os.path.join(tmpdir, 'tf_checkpoints')
)

Deep Learning Pipeline

batch_size = 100
epochs = 3
validation_size = 0.15
max_plotted_validation_predictions = 10

seq2seq_pipeline_hyperparams = HyperparameterSamples({
    'hidden_dim': 100,
    'layers_stacked_count': 2,
    'lambda_loss_amount': 0.0003,
    'learning_rate': 0.006,
    'window_size_future': sequence_length,
    'output_dim': output_dim,
    'input_dim': input_dim
})
feature_0_metric = metric_3d_to_2d_wrapper(mean_squared_error)
metrics = {'mse': feature_0_metric}

signal_prediction_pipeline = Pipeline([
    TrainOnly(DataShuffler()),
    WindowTimeSeries(),
    MeanStdNormalizer(),
    MiniBatchSequentialPipeline([
        Tensorflow2ModelStep(
            create_model=create_model,
            create_loss=create_loss,
            create_optimizer=create_optimizer,
            print_loss=True
        ).set_hyperparams(seq2seq_pipeline_hyperparams)
    ])
])

pipeline, outputs = pipeline.fit_transform(data_inputs, expected_outputs)

Metadata

Release files for neuraxle-tensorflow 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neuraxle-tensorflow 0.1.2
File Size Uploaded Provenance Actions
neuraxle_tensorflow-0.1.2.tar.gz 8.4 kB Without provenance Details for neuraxle_tensorflow-0.1.2.tar.gz

Release files / neuraxle_tensorflow-0.1.2.tar.gz

Download URL neuraxle_tensorflow-0.1.2.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6c60a9e6aa4a4b3b5b5639b267d08cfac1f4425ff3998133605f96b2f80299ee
BLAKE2b-256 checksum
How to use checksums
d947f123f87c57ffc20d1f02ef2733d6e6b0e54fb03c46eedb3839a5a8420e02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

Security for neuraxle-tensorflow 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page