Code Monkey home page Code Monkey logo

Comments (4)

NEGU93 avatar NEGU93 commented on May 27, 2024

It is indeed strange, at some point the data is becoming real valued. I have some request if you could.

  1. Can you show me the output of model.summary()?
  2. Which version of the code are you using? Be sure to always keep the last version and try to favour PIP over ANACONDA.
  3. Could you provide a MWE? Maybe generate a random dataset and upload the code. If you use Google colab you can even run the code on a cloud.

Thank you very much.

from cvnn.

NEGU93 avatar NEGU93 commented on May 27, 2024

I am closing this issue due to inactivity. If you (or someone) come across this issue again just comment and I will re-open it.

from cvnn.

cboily avatar cboily commented on May 27, 2024

Hello!

Thank you very much for this library to treat complex values.

I have the same issue. The warning appears for the 3rd layer of after the I used the code you provided in the doc of the simple example, https://complex-valued-neural-networks.readthedocs.io/en/latest/cvnn.html.

The code used
import numpy as np
import cvnn.layers as complex_layers
import tensorflow as tf

def get_dataset():
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.cifar10.load_data()
train_images = train_images.astype(dtype=np.complex64) / 255.0
test_images = test_images.astype(dtype=np.complex64) / 255.0
return (train_images, train_labels), (test_images, test_labels)
p=tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(p[0], True)
(train_images, train_labels), (test_images, test_labels) = get_dataset() # to be done by each user

model = tf.keras.models.Sequential()
model.add(complex_layers.ComplexInput(input_shape=(32, 32, 3))) # Always use ComplexInput at the start
model.add(complex_layers.ComplexConv2D(32, (3, 3), activation='cart_relu'))
model.add(complex_layers.ComplexAvgPooling2D((2, 2)))
model.add(complex_layers.ComplexConv2D(64, (3, 3), activation='cart_relu'))
model.add(complex_layers.ComplexMaxPooling2D((2, 2)))

model.add(complex_layers.ComplexConv2D(64, (3, 3), dtype=np.complex64, activation='cart_relu'))
model.add(complex_layers.ComplexFlatten())
model.add(complex_layers.ComplexDense(64, activation='cart_relu'))
model.add(complex_layers.ComplexDense(10, activation='convert_to_real_with_abs'))
model.compile(optimizer='adam',
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'])
model.summary()
#p=tf.config.list_physical_devices('GPU')

#Train model
history = model.fit(train_images, train_labels, epochs=6, validation_data=(test_images, test_labels))

#Evaluate model
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)

The output of the terminal
Model: "sequential"


Layer (type) Output Shape Param #

complex_conv2d (ComplexConv2 (None, 30, 30, 32) 1792


complex_avg_pooling2d (Compl (None, 15, 15, 32) 0


complex_conv2d_1 (ComplexCon (None, 13, 13, 64) 36992


complex_max_pooling2d (Compl (None, 6, 6, 64) 0


complex_conv2d_2 (ComplexCon (None, 4, 4, 64) 73856


complex_flatten (ComplexFlat (None, 1024) 0


complex_dense (ComplexDense) (None, 64) 131200


complex_dense_1 (ComplexDens (None, 10) 1300

Total params: 245,140
Trainable params: 245,140
Non-trainable params: 0


2022-04-07 17:48:26.016937: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 1228800000 exceeds 10% of free system memory.
Epoch 1/6
WARNING: complex_conv2d_2 - Expected input to be <dtype: 'complex64'>, but received <dtype: 'float32'>.
This is normally fixed using ComplexInput() at the start (tf casts input automatically to real).

The library was install with pip and the version is 1.0.0.

Thank you very much.

from cvnn.

NEGU93 avatar NEGU93 commented on May 27, 2024

I don't have this problem. Here you have the notebook with the code.

Please be sure to update the library cvnn just in case.

from cvnn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.