Coder Social home page Coder Social logo

Comments (3)

hhjung1202 avatar hhjung1202 commented on July 18, 2024

im sorry i know that vj is like unit vector of 16 D

from capsnet-tensorflow.

naturomics avatar naturomics commented on July 18, 2024

You do not understand squashing correctly. Squashing ensures the length (euclidean norm) of its output vector is in [0, 1], not about the element in the vector. Have fun with the following code:

import numpy as np
from matplotlib import pyplot as plt

def squash(vector, axis=None):

norm = np.linalg.norm(vector, axis=axis, keepdims=True)`
norm_squared = np.square(norm)
scalar_factor = norm_squared / (1 + norm_squared)
return scalar_factor * (vector / norm)

#Create 10000 samples each with 3 elements
num_samples = 10000
c1 = np.random.uniform(size=(num_samples, 1))
c2 = np.random.normal(size=(num_samples, 1))
c3 = np.random.logistic(size=(num_samples, 1))
vectors = np.hstack((c1, c2, c3)) # [num_samples, 3]
squashed_vector = squash(vectors, axis=1)
length = np.sqrt(np.sum(np.square(squashed_vector), axis=1))
plt.plot(np.sort(length))

from capsnet-tensorflow.

parinaya-007 avatar parinaya-007 commented on July 18, 2024

Look "reduce_mean" function in utils.py carefully and also after this function is applied using axis=2, we are taking the mean of the sum of squared sum of vector so the range is not (-4, 4) it is (0, 1).

from capsnet-tensorflow.

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.