Git Product home page Git Product logo

sascha-kirch / deepsaki Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 0.0 3.5 MB

DeepSaki is an add-on to TensorFlow. It provides a variaty of custom classes ranging from activation functions to entire models, helper functions to facilitate connectiong to your, compute HW and many more!

Home Page: https://sascha-kirch.github.io/DeepSaki/

License: MIT License

Python 99.62% Dockerfile 0.19% HTML 0.18%
computer-vision deep-learning distributed machine-learning mit-license python tensorflow tpu

deepsaki's Introduction

Hi there ๐Ÿ‘‹

My name is Sascha and I am a PhD Student working in the field of deeplearning. I am a hardware and software engineer.

  • ๐Ÿ”ญ Iโ€™m currently working on generative multi-modal deeplearning for depth estimation of scenes and have been working adversarial domain adaptation for RGBD data before
  • ๐Ÿ‘ฏ Iโ€™m open to collaborate on interesting new topics to meet new people and learn new things!
  • โœŒ๏ธ I hope my repos are usefull to you and would be happy for any constructive feedback and suggestion to further improve

To find out more about me check out my website: https://sascha-kirch.github.io/

since 04.01.2022

Star History

Star History Chart

deepsaki's People

Contributors

sascha-kirch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

deepsaki's Issues

Support * for imports

To support "from DeepSaki import *" I need to change the init.py files and add support for all

improve imports of __init__.py files

Currently in the initi.py the exposed api's are imported. The issue is that then everytime everything is imported, eventhough I might only import a single API.

Previw image of website

Preview image on the documentation is cropped. The aspect ratio of the logo must be adapted.

rFFTPooling2D() in fourier_pooling.py is no valid operation

The sequence length of the DFT and the iDFT must have the same length in order for the cropping operation to have the desired effect.

The cropping in the frequency domain only makes sence, if not transformed back to the spatial domain. It should stay in the frequency domain, cropped several times and then finally can either be fed to a classification head to classify in the frequency domain or to transform back into the spatial domain using the initial sequence length.

FourierConvolution2D () in fourier_layer.py does not consider circular convolution

The convolution theorem for DFTs differs from standard fourier transforms.
Solution:

  1. Zero Pad image
  2. DFT, multiply, iDFT
  3. circulate result
  4. crop to original size

Code:

def call(self, inputs):
if not self.built:
raise ValueError('This model has not yet been built.')
#FFT2D is calculated over last two dimensions!
if not self.isChannelFirst:
inputs = tf.einsum("bhwc->bchw",inputs)
outputs_F = np.ndarray(shape=self.out_shape)
# Pad the kernel to the shape of the input to enable element-wise multiplication
signal_shape = tf.shape(inputs)
kernel_shape = tf.shape(self.kernel)
x_pad = signal_shape[2] - kernel_shape[2]
y_pad = signal_shape[3] - kernel_shape[3]
# paddings shape is [2,4] because rank of inputs is 4, and 2 for height and width
paddings = [[0,0],
[0,0],
[0,x_pad],
[0,y_pad]
]
kernels_padded = tf.pad(self.kernel, paddings) # [out_channels, inp_channel, height,width,out_channe]
#print("Shape: inputs {}".format(np.shape(inputs)))
#print("Shape: kernels_padded {}".format(np.shape(kernels_padded)))
# Compute DFFTs for both inputs and kernel weights
inputs_F = tf.signal.rfft2d(inputs) #[batch,height,width,channel]
kernels_F = tf.signal.rfft2d(kernels_padded)
#kernels_F = tf.math.conj(kernels_F) #calculate conjugate to be mathematically correct with the cross-corelation implementation. Not important, since filter is learned!
#print("Shape: inputs_F {}".format(np.shape(inputs_F)))
#print("Shape: kernels_F {}".format(np.shape(kernels_F)))
# Apply filters by element wise multiplications
for filter in range(self.filters):
#print("Shape: kernels_F[filter,:,:,:] {}".format(np.shape(kernels_F[filter,:,:,:])))
outputs_F = tf.concat(
[outputs_F,
tf.reduce_sum(
inputs_F * kernels_F[filter,:,:,:], #inputs:(batch, inp_filter, height, width ), fourier_filter:(...,out_filter,inp_filter,height, width)
axis = -3, # sum over all applied filters
keepdims = True
)],
axis = -3 # is the new filter count, since channel first
)
#print("Shape: outputs_F {}".format(np.shape(outputs_F)))
# Inverse rDFFT
output = tf.signal.irfft2d(outputs_F)
#output = tf.math.real(output)
if self.use_bias:
output += self.bias
#reverse the channel configuration to its initial config
if not self.isChannelFirst:
output = tf.einsum("bchw->bhwc",output)
return output

TensorFlow Addons depricated

TFA will not be supported anymore soon. Despite the anoying warning that can't be surpressed, I'd like to remove the dependency on that library and refactor the code to not depend on it anymore.

FourierLayer() has instance methods that do not act on the instance.

FourierLayer() has methods like _matrix_product() or _change_to_channel_first() that do not require the instance of the class.
They have been simply put into a base class that is then inherited from.
So it is actually not really a base class but rather a collection of functions used in the child classes.

They could be turned into static methods.

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.