-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Carlota de la Vega
committed
May 14, 2024
1 parent
03d52db
commit 03bf79e
Showing
11 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Pytest | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pytest | ||
- name: Testing the code with pytest | ||
run: | | ||
pytest -v |
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import tensorflow as tf | ||
from src.cGAN import conditionalGAN | ||
|
||
class TestConditionalGAN: | ||
@classmethod | ||
def setup_class(cls): | ||
discriminator = tf.keras.models.Sequential() | ||
generator = tf.keras.models.Sequential() | ||
latent_dim = 100 | ||
image_size = 28 | ||
num_classes = 10 | ||
cls.cgan = conditionalGAN(discriminator, generator, latent_dim, image_size, num_classes) | ||
cls.cgan.compile( | ||
d_optimizer=tf.keras.optimizers.Adam(), | ||
g_optimizer=tf.keras.optimizers.Adam(), | ||
loss_fn=tf.keras.losses.BinaryCrossentropy(), | ||
) | ||
|
||
def test_train_step(self): | ||
# Create dummy data for testing | ||
real_images = tf.random.normal((32, 28, 28, 1)) | ||
one_hot_labels = tf.one_hot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], depth=10) | ||
|
||
# Perform a single train step | ||
train_logs = self.cgan.train_step((real_images, one_hot_labels)) | ||
|
||
# Check if the loss values are updated | ||
assert "g_loss" in train_logs | ||
assert "d_loss" in train_logs | ||
assert train_logs["g_loss"] != 0.0 | ||
assert train_logs["d_loss"] != 0.0 | ||
|
||
def test_metrics(self): | ||
# Check if the metrics are correctly initialized | ||
metrics = self.cgan.metrics | ||
assert len(metrics) == 2 | ||
assert isinstance(metrics[0], tf.keras.metrics.Mean) | ||
assert isinstance(metrics[1], tf.keras.metrics.Mean) |
Empty file.