Coder Social home page Coder Social logo

tripletnet's Issues

what is L2-norm Layer's role?

import numpy as np
epsilon = 1e-12
x =np.array([0.0000002,0.0000002,0.00000033])
print(sum(x**2))
print(x/np.sqrt(epsilon))
print(x/np.sqrt(sum(x**2)))
x/np.sqrt(max(sum(x**2), epsilon))

output

1.889e-13
[ 0.2   0.2   0.33]
[ 0.46016546  0.46016546  0.75927301]
array([ 0.2 ,  0.2 ,  0.33])

train tripletNet with images of Nogizaka and confirm the behavior

import numpy as np
import os.path

class IdentityMetadata():
    def __init__(self, base, name, file):
        # dataset base directory
        self.base = base
        # identity name
        self.name = name
        # image file name
        self.file = file

    def __repr__(self):
        return self.image_path()

    def image_path(self):
        return os.path.join(self.base, self.name, self.file) 
    
def load_metadata(path):
    metadata = []
    for i in os.listdir(path):
        for f in os.listdir(os.path.join(path, i)):
            metadata.append(IdentityMetadata(path, i, f))
    return np.array(metadata)

metadata = load_metadata('images')

クラスを作成してfilename,とデータを紐付ける。

論文まとめ

せっかく読んでも後で見直すのが面倒なので、新しくipadにノート作ってまとめる。

Something wrong with triplet-loss

why loss: 0.0000e+00 ?

Epoch 1/10
400/400 [==============================] - 6s 15ms/step - loss: 3278.5809
Epoch 2/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 3/10
400/400 [==============================] - 4s 9ms/step - loss: 778.3205
Epoch 4/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 5/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 6/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 7/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 8/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 9/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00
Epoch 10/10
400/400 [==============================] - 4s 9ms/step - loss: 0.0000e+00

somthing wrong with "plt.imshow(img)"

img = np.array(Image.open('path').resize((w,h)))
img = (img/255.).astype(np.float32)
plt.imshow(img)

if I exec this code, normal image comes up...Why?

How can I get the embedded vectors?

embedded = np.zeros((metadata.shape[0], 128))

for i, m in enumerate(metadata):
    img = load_image(m.image_path())
    img = align_image(img)
    # scale RGB values to interval [0,1]
    img = (img / 255.).astype(np.float32)
    # obtain embedding vector for image
    embedded[i] = nn4_small2_pretrained.predict(np.expand_dims(img, axis=0))[0]

predict( )[0]なのでpredictしたうちのanchorに相当する値を取り出しemb_vecとしている?
expand_dims : [a,b,c] -> [[a,b,c]]

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.