Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:

- name: Install Xircuits
run: |
whl_name=$(echo dist/*whl)[learning]
whl_name=$(echo dist/*whl)[tensorflow_keras]
pip install $whl_name

- name: Setup Playwright
Expand Down
149 changes: 75 additions & 74 deletions examples/KerasModelPredict.xircuits

Large diffs are not rendered by default.

1,046 changes: 545 additions & 501 deletions examples/KerasTrainImageClassifier.xircuits

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/KerasTransferLearning.xircuits
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@
"selected": false,
"extras": {
"type": "eval",
"path": "xai_components/xai_learning/keras_transfer_learning.py",
"path": "xai_components/xai_tensorflow_keras/keras_transfer_learning.py",
"description": "Evaluate the accuracy of a Tensorflow Keras model using a Tensorflow\ndataset (`tensorflow.data.Dataset`)\n\n##### inPorts:\n- model: trained tensorflow keras model.\n- eval_dataset: dataset to evaluate. Instance of `tensorflow.data.Dataset`.\n\n##### outPorts:\n- metrics: `dict` model loss and accuracy.",
"lineNo": [
{
Expand Down Expand Up @@ -1308,7 +1308,7 @@
"selected": false,
"extras": {
"type": "train",
"path": "xai_components/xai_learning/keras_transfer_learning.py",
"path": "xai_components/xai_tensorflow_keras/keras_transfer_learning.py",
"description": "Trains a keras model.\n\n##### inPorts:\n- model: compiled model.\n- training data: tensorflow keras model compatible dataset\n- batch_size: `int` or `None`. Number of samples per gradient update.\n- epochs: `int` number of epochs to train the model.\n- kwargs: `dict` optional. Other `tf.model.fit` arguments.\n\n##### outPorts:\n- trained_model: trained tensoflow keras model.\n- training_metrics: `dict`, training metrics from training history.",
"lineNo": [
{
Expand Down Expand Up @@ -1467,7 +1467,7 @@
"selected": false,
"extras": {
"type": "debug",
"path": "xai_components/xai_learning/keras_transfer_learning.py",
"path": "xai_components/xai_tensorflow_keras/keras_transfer_learning.py",
"description": "Compiles a Tensorflow Keras model.\n\n##### References:\n- [Tensorflow Keras\nOptimizers](https://www.tensorflow.org/api_docs/python/tf/keras/optimizers)\n- [Tensorflow Keras\nlosses](https://www.tensorflow.org/api_docs/python/tf/keras/losses)\n- [Tensorflow Keras\nMetrics](https://www.tensorflow.org/api_docs/python/tf/keras/metrics)\n- [Tensorflow Keras loss\nidentifier](https://www.tensorflow.org/api_docs/python/tf/keras/losses/get#expandable-1)\n\n##### inPorts:\n- model: tensorflow keras model to compile.\n- optimizer_identifier: `any`, valid tensorflow keras optimizer identifier,\ne.g, `adam` or `Adam` for default arguments, `{\"class_name\": \"Adam\",\n\"config\": {\"learning_rate\": 0.001}}` to specify keyword arguments.\n- loss_identifier: `any`, valid tensorflow keras loss identifier, e.g,\n`categorical_crossentropy` or `CategoricalCrossentropy` for a loss as a\n[function](https://www.tensorflow.org/api_docs/python/tf/keras/losses#functions_2),\nor a\n[class](https://www.tensorflow.org/api_docs/python/tf/keras/losses#classes_2),\n`{\"class_name\": \"CategoricalCrossentropy\", \"config\": {\"from_logits\": True}`\nto pass in keyword arguments. Check out the [identifier\ndocumentation](https://www.tensorflow.org/api_docs/python/tf/keras/losses/get#expandable-1)\nfor more details. \n- metrics: `list` list of metrics to be evaluated by the model during\ntraining and testing. Each metric should be a string of a metric identifier,\ne.g, ['accuracy', 'mse', ... ].\n\n##### outPorts:\n- compiled_model: compiled tensorflow keras model\n- model_config: `dict` model configuration.",
"lineNo": [
{
Expand Down Expand Up @@ -1611,7 +1611,7 @@
"selected": false,
"extras": {
"type": "model",
"path": "xai_components/xai_learning/keras_transfer_learning.py",
"path": "xai_components/xai_tensorflow_keras/keras_transfer_learning.py",
"description": "Fetch Tensorflow Keras Model by name, for transfer learning.\n\n##### Reference:\n- [Keras Application\nFunctions](https://www.tensorflow.org/api_docs/python/tf/keras/applications#functions_2)\n\n##### inPorts:\n- base_model_name: `str`, name of model (case sensitive). The\nbase_model_name must be listed under the functions\n[here](https://www.tensorflow.org/api_docs/python/tf/keras/applications#functions_2)\n- include_top: `bool`, whether to include the fully connected layers at\nthe top of the network. Defaults to `True`.\n- weights: `str` pretrained weights to use. Defaults to `imagenet`.\n- input_shape: `tuple` optional shape tuple, only to be specified if\ninclude_top is False (otherwise the input shape has to be (224, 224, 3)\n(with channels_last data format) or (3, 224, 224) (with channels_first\ndata format). It should have exactly 3 input channels, and width and\nheight should be no smaller than 32. E.g. (200, 200, 3) would be one\nvalid value.\n- freeze_all: `bool`, whether to freeze the weights in all layers of the\nbase model. Defaults to `True`.\n- fine_tune_from: `int`, base model layer to fine tune from. Example,\nsetting fine_tune_from=5 for a pretrained model with 25 layers will\nfreeze only the first 5 layers. This will only take effect if freeze_all\nis set to `False`. Defaults to `0` (freeze_all=True).\n- classes: `int` number of classes to classify images into, only to be\nspecified if `include_top` is `True`, and if no `weights` argument is\nspecified.\n- binary: `bool` whether this model will be used for binary classification.\nDefaults o `False`.\n- classifier_activation: `str` or `callable`. The activation function to\nuse on the \"top\" layer. Ignored unless `include_top=True`. Set\n`classifier_activation=None` to return the logits of the \"top\" layer.\nWhen loading pretrained weights, classifier_activation can only be None\nor \"softmax\".\n- kwargs: `dict`, optional. Passed to the model class. Please refer to the\nspecific tensorflow keras model documentation for other model specific\nkeyword arguments.\n\n##### outPorts:\n- model: tensorflow keras model.",
"lineNo": [
{
Expand Down Expand Up @@ -1824,7 +1824,7 @@
"selected": false,
"extras": {
"type": "debug",
"path": "xai_components/xai_learning/keras_transfer_learning.py",
"path": "xai_components/xai_tensorflow_keras/keras_transfer_learning.py",
"description": "Fetch Tensorflow Dataset by name\n\n##### Reference:\n- [Tensorflow Datasets\nCatalog](https://www.tensorflow.org/datasets/catalog/overview)\n\n##### inPorts:\n- dataset_name: `str`, name of dataset, as listed on [Tensorflow Datasets\ncatalog](https://www.tensorflow.org/datasets/catalog/overview)\n- batch_size: `int`, if set, add a batch dimension to the dataset.\nDefaults to `32`.\n- shuffle_files: `bool`, whether to shuffle the input files. Defaults to\n`False`.\n- as_supervised: `bool`, if `True`, the returned `tf.data.Dataset` will\nhave a 2-tuple structure `(input, label)` according to\n`builder.info.supervised_keys`. If `False`, the default, the returned\n`tf.data.Dataset` will have a dictionary with all the features.\n- kwargs: `dict`, optional. Passed to `tfds.load`. Please refer to the\nspecific tensorflow dataset documentation for other dataset specific\nkeyword arguments.\n\n##### outPorts:\n- all_data: `dict<key: tfds.Split, value: tf.data.Dataset>`, all available\ndataset.\n- train_data: `tf.data.Dataset`, train split if available\n- test_data: `tf.data.Dataset`, test split if available",
"lineNo": [
{
Expand Down Expand Up @@ -2024,7 +2024,7 @@
"selected": false,
"extras": {
"type": "debug",
"path": "xai_components/xai_learning/keras_transfer_learning.py",
"path": "xai_components/xai_tensorflow_keras/keras_transfer_learning.py",
"description": "Saves a Tensorflow Keras model.\n\n##### inPorts:\n- model: tensorflow keras model to save\n- model_name: `str` name to save the model as\n ",
"lineNo": [
{
Expand Down
2 changes: 1 addition & 1 deletion xai_components/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ These components will always be included in the Xircuits installation.

| Name | Description | |
| -------- | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Learning | Deep learning related components using Tensorflow Keras. | [Link](https://github.com/XpressAI/xircuits/tree/master/xai_components/xai_learning) |
| Tensorflow Keras | Deep learning related components using Tensorflow Keras. | [Link](https://github.com/XpressAI/xircuits/tree/master/xai_components/xai_tensorflow_keras) |
| Pytorch | Components that use Pytorch's ML library. | [Link](https://github.com/XpressAI/xircuits/tree/master/xai_components/xai_pytorch) |
| Spark | Components built using the Pyspark library. Run these components with the Xircuits Remote Run! | [Link](https://github.com/XpressAI/xircuits/tree/master/xai_components/xai_spark) |
| Template | Great components for new learners and to experiment outputs. | [Link](https://github.com/XpressAI/xircuits/tree/master/xai_components/xai_template) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def execute(self, ctx):
self.compiled_model.value = self.model.value
model_config = {
"lr": self.compiled_model.value.optimizer.lr.numpy().item(),
"optimizer_name": self.compiled_model.value.optimizer._name,
"optimizer_name": self.compiled_model.value.optimizer.name,
"loss": self.compiled_model.value.loss,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path

@xai_component
class ReadDataSet(Component):
class ReadKerasDataSet(Component):
"""Loads a Keras image dataset or creates a dataset from a directory.

### Reference:
Expand Down Expand Up @@ -244,7 +244,7 @@ def execute(self, ctx) -> None:
self.done = True

@xai_component
class Create1DInputModel(Component):
class KerasCreate1DInputModel(Component):
"""Takes a 1D dataset tuple and creates a 1D Keras model.

##### inPorts:
Expand Down Expand Up @@ -283,7 +283,7 @@ def execute(self, ctx) -> None:
self.done = True

@xai_component
class Create2DInputModel(Component):
class KerasCreate2DInputModel(Component):
"""Takes a 2D dataset tuple and creates a 2D Keras model.

##### inPorts:
Expand Down Expand Up @@ -332,10 +332,10 @@ def execute(self, ctx) -> None:
optimizer='adam',
metrics=['accuracy']
)

model_config = {
'lr': model.optimizer.lr.numpy().item(),
'optimizer_name': model.optimizer._name,
'optimizer_name': model.optimizer.name,
'loss': model.loss,
}

Expand All @@ -346,7 +346,7 @@ def execute(self, ctx) -> None:


@xai_component
class TrainImageClassifier(Component):
class KerasTrainImageClassifier(Component):
"""Trains a Keras model for image classification.

##### inPorts:
Expand Down Expand Up @@ -399,7 +399,7 @@ def execute(self, ctx) -> None:


@xai_component
class EvaluateAccuracy(Component):
class KerasEvaluateAccuracy(Component):
"""Evaluates a Keras model against a dataset

##### inPorts:
Expand Down