Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mnist convert from tensorflow to ggml #744

Open
datduonguva opened this issue Feb 22, 2024 · 0 comments
Open

mnist convert from tensorflow to ggml #744

datduonguva opened this issue Feb 22, 2024 · 0 comments

Comments

@datduonguva
Copy link

in the file examples/mnist/mnist-cnn.py

    kernel1 = model.layers[0].weights[0].numpy()                                                    
    kernel1 = np.moveaxis(kernel1, [2,3], [0,1])                                                    
    kernel1 = kernel1.astype(np.float16)                                                            
    gguf_writer.add_tensor("kernel1", kernel1, raw_shape=(32, 1, 3, 3))                             
    ...                                                                                                
    kernel2 = model.layers[2].weights[0].numpy()                                                    
    kernel2 = np.moveaxis(kernel2, [0,1,2,3], [2,3,1,0])                                            
    kernel2 = kernel2.astype(np.float16)                                                            
    gguf_writer.add_tensor("kernel2", kernel2, raw_shape=(64, 32, 3, 3)) 

why are kernel1's axes and kernel2's axes moved by np.moveaxis differently?

kernel1 has shape (3, 3, 1, 32) so after np.moveaxis(kernel1, [2, 3], [0, 1]), its shape will be (1, 32, 3, 3), NOT (32, 1, 3, 3) as showned on the next line.

Wondering if this is a bug.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant