Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

ValueError #7

Open
adeyris opened this issue Apr 17, 2018 · 15 comments
Open

ValueError #7

adeyris opened this issue Apr 17, 2018 · 15 comments
Labels
enhancement New feature or request

Comments

@adeyris
Copy link

adeyris commented Apr 17, 2018

Hi ! Thanks for this contribution :)

I'm trying to run ann-visualizer on keras-RetinaNet, but I get this error :

ValueError: invalid literal for int() with base 10: 'Non'

Any idea of how to solve it ?

@RedaOps
Copy link
Owner

RedaOps commented Apr 17, 2018

Can you provide a code sample?

@RedaOps
Copy link
Owner

RedaOps commented Apr 17, 2018

It seems like keras-RetinaNet uses a DenseNet object to build the network. Our library only supports Sequential objects at this time.

@RedaOps RedaOps added the enhancement New feature or request label Apr 17, 2018
@z2e2
Copy link

z2e2 commented Apr 20, 2018

I run into the same issue. It says ValueError: invalid literal for int() with base 10: ''. I think it is because you try to parse the input shape using the following command:
str(input_shape).split(',')[1][1:-1]
But the problem with my keras is that my keras input shape is (None, 4, 125).
I don't think the code works for this case. Is my keras version different from yours?

@RedaOps
Copy link
Owner

RedaOps commented Apr 24, 2018

@ZZHAOatEESI Are you passing the ann_viz() function a Model or a Sequential object?

@shivam05011996
Copy link

@Prodicode
I have a siamese network, trying to visualise it but got this error -

raise ValueError("ANN Visualizer: Layer not supported for visualizing");
ValueError: ANN Visualizer: Layer not supported for visualizing

I have tried various methods to make it visualise but nothing helps. Any help is appreciated.

Model Summary -

__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            (None, 300)          0                                            
__________________________________________________________________________________________________
input_2 (InputLayer)            (None, 300)          0                                            
__________________________________________________________________________________________________
sequential_1 (Sequential)       (None, 300)          564200      input_1[0][0]                    
                                                                 input_2[0][0]                    
__________________________________________________________________________________________________
lambda_1 (Lambda)               (None, 1)            0           sequential_1[1][0]               
                                                                 sequential_1[2][0]               
==================================================================================================
Total params: 564,200
Trainable params: 564,200
Non-trainable params: 0

@RedaOps
Copy link
Owner

RedaOps commented May 2, 2018

@shivam-deepcompute Can you provide the piece of code where you build the keras Sequential model? (Layer by layer)

@shivam05011996
Copy link

shivam05011996 commented May 3, 2018

@Prodicode

def _create_base_network(self, input_dim):
    a = 'softsign'
    network = Sequential()
    network.add(Dense(1000, input_shape=(input_dim,), activation=a)
    network.add(Dense(150, input_shape=(input_dim,), activation=a))
    network.add(Dense(250, input_shape=(input_dim,), activation=a))
    network.add(Dense(300, input_shape=(input_dim,), activation='sigmoid')
    return network

This is my base sequential network, which accepts two inputs, as mentioned in the model summary. I hope this what you asked.

@thpatty
Copy link

thpatty commented May 5, 2018

@Prodicode

hello, i use your example , but i met this error below, can you help me ?
i use windows 10 and jupyter notebook. i can see the two files in the same file directory with *.ipynb
i can open the network.gv.pdf with chrome, i just only can see the first two layers. what is wrong with it?

thanks firstly.

OSError Traceback (most recent call last)
in ()
50
51 model = build_cnn_model()
---> 52 ann_viz(model, title="")

C:\ProgramData\Anaconda3\lib\site-packages\ann_visualizer\visualize.py in ann_viz(model, view, filename, title)
204 g.edge_attr.update(arrowhead="none", color="#707070");
205 if view == True:
--> 206 g.view();

C:\ProgramData\Anaconda3\lib\site-packages\graphviz\files.py in view(self, filename, directory, cleanup)
201 """
202 return self.render(filename=filename, directory=directory, view=True,
--> 203 cleanup=cleanup)
204
205 def _view(self, filepath, format):

C:\ProgramData\Anaconda3\lib\site-packages\graphviz\files.py in render(self, filename, directory, view, cleanup)
180
181 if view:
--> 182 self._view(rendered, self._format)
183
184 return rendered

C:\ProgramData\Anaconda3\lib\site-packages\graphviz\files.py in _view(self, filepath, format)
216 raise RuntimeError('%r has no built-in viewer support for %r '
217 'on %r platform' % (self.class, format, backend.PLATFORM))
--> 218 view_method(filepath)
219
220 _view_darwin = staticmethod(backend.view.darwin)

C:\ProgramData\Anaconda3\lib\site-packages\graphviz\backend.py in view_windows(filepath)
227 def view_windows(filepath):
228 """Start filepath with its associated application (windows)."""
--> 229 os.startfile(os.path.normpath(filepath))

OSError: [WinError -2147221003] Application not found: 'network.gv.pdf'

import keras;
from keras.models import Sequential;
from keras.layers import Conv2D, Dense, Dropout, MaxPooling2D, Flatten;
from ann_visualizer.visualize import ann_viz

def build_cnn_model():
model = keras.models.Sequential()

model.add(
Conv2D(
32, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(Dropout(0.2))

model.add(
Conv2D(
32, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.2))

model.add(
Conv2D(
64, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(Dropout(0.2))

model.add(
Conv2D(
64, (3, 3),
padding="same",
input_shape=(32, 32, 3),
activation="relu"))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.2))

model.add(Flatten())
model.add(Dense(512, activation="relu"))
model.add(Dropout(0.2))

model.add(Dense(10, activation="softmax"))

return model

model = build_cnn_model()
ann_viz(model, title="")

@LeandroRitter
Copy link

Hi!

I am using ANN Visualizer to display concatenated/merged layers but get errors, could you direct me how to properly visualize concatenated layers? Here is my code:

import keras;
from keras.models import Sequential;
from keras.layers import Dense, Concatenate, Merge;

network = Sequential();
network.add(Dense(units=6,
activation='relu',
kernel_initializer='uniform',
input_dim=11));

network.add(Dense(units=6,
activation='relu',
kernel_initializer='uniform'));

another_network = Sequential();
another_network.add(Dense(units=6,
activation='relu',
kernel_initializer='uniform',
input_dim=11));

#result = Sequential();
result = Merge([network, another_network], mode='concat')

#result.add(Dense(units=1,

activation='sigmoid',

kernel_initializer='uniform'));

from ann_visualizer.visualize import ann_viz;

ann_viz(result, title = "", view = True);

and here is the error:


ValueError Traceback (most recent call last)
in ()
28 from ann_visualizer.visualize import ann_viz;
29
---> 30 ann_viz(result, title = "Autoencoder", view = True);
31 #convert -density 200 network.gv.pdf network.gv.png

~/miniconda3/lib/python3.6/site-packages/ann_visualizer/visualize.py in ann_viz(model, view, filename, title)
121 c.node(str(n), label="Image\n"+pxls[1]+" x"+pxls[2]+" pixels\n"+clrmap, fontcolor="white");
122 else:
--> 123 raise ValueError("ANN Visualizer: Layer not supported for visualizing");
124 for i in range(0, hidden_layers_nr):
125 with g.subgraph(name="cluster_"+str(i+1)) as c:

ValueError: ANN Visualizer: Layer not supported for visualizing

@endolith
Copy link

endolith commented Aug 7, 2018

Same error:

model = Sequential([
    Dense(2, input_shape=(N, 2), use_bias=False)
    ])

ann_viz(model)
Traceback (most recent call last):

  File "<ipython-input-79-02a59322b308>", line 1, in <module>
    ann_viz(model)

  File "C:\Anaconda3\lib\site-packages\ann_visualizer\visualize.py", line 42, in ann_viz
    input_layer = int(str(layer.input_shape).split(",")[1][1:-1]);

ValueError: invalid literal for int() with base 10: ''

@smholsen
Copy link

I am also having the same issue with the following model. Do you know how to fix this? :)

            self.base_model = Sequential()
            self.base_model.add(Conv2D(20, input_shape=(5, 25, 1), kernel_size=(3, 3), strides=(1, 1), padding='same', activation='relu'))
            self.base_model.add(Flatten())
            self.base_model.add(Dropout(.4))
            self.base_model.add(Dense(1))
            # Compile model
            # self.base_model.summary()
            self.base_model.compile(loss='mse', optimizer='adam')
            self.base_model.fit(X1, y1, epochs=500, batch_size=128)
            ann_viz(self.base_model, title="ANN Topology")
  File "...\venv\lib\site-packages\ann_visualizer\visualize.py", line 42, in ann_viz
    input_layer = int(str(layer.input_shape).split(",")[1][1:-1]);
ValueError: invalid literal for int() with base 10: ''

@thpatty
Copy link

thpatty commented Nov 14, 2018 via email

@Asrix-AI
Copy link

@shivam05011996 Did you get the solution?

@ShrikanthSingh
Copy link

ShrikanthSingh commented Feb 5, 2020

<ipython-input-271-6323c76e75d0> in <module>()
    16 # load weights into new model
    17 model.load_weights("model.h5")
---> 18 ann_viz(model, title="Artificial Neural network - Model Visualization")

/usr/local/lib/python3.6/dist-packages/ann_visualizer/visualize.py in ann_viz(model, view, filename, title)
    40     for layer in model.layers:
    41         if(layer == model.layers[0]):
---> 42             input_layer = int(str(layer.input_shape).split(",")[1][1:-1]);
    43             hidden_layers_nr += 1;
    44             if (type(layer) == keras.layers.core.Dense):

ValueError: invalid literal for int() with base 10: ''```


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants