Giter Site home page Giter Site logo

Comments (2)

cosmic-cortex avatar cosmic-cortex commented on June 6, 2024

Hi!

As far as I understand the scikit-learn wrapper for Keras, it constructs the model using the build function you provide during the .fit() method, which is stored in the model attribute. From the error log you posted, I suspect the problem is that the model has not been constructed yet when you call learner.query(). Let me know if it helps!

from modal.

awalker0215 avatar awalker0215 commented on June 6, 2024

Thank you for your answer.
I change keras library from tensorflow to origin,use example code from github and it can work.
finally code as following:
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=(28, 28, 1)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(10, activation='softmax'))
try:
_model = keras.utils.multi_gpu_model(model,gpus=2)
print("Training using multiple GPUs..")
except ValueError:
_model = model
print("Training using single GPU or CPU..")
_model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])
However,I used resnet50 in keras as my learner,another error occurred
with tensorflow.device('/cpu:0'):
model = Sequential()
model.add(resnet50.ResNet50(include_top = False, pooling = 'avg', weights = None,input_tensor=Input(shape=(28, 28, 1))))
model.add(Dense(10, activation = 'softmax'))
adam = optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0, amsgrad=False)

and error is :

Training using multiple GPUs..
WARNING:tensorflow:From /home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
Traceback (most recent call last):
File "/home/es712/Documents/MingHan/pycode/test/ALtest.py", line 92, in
verbose=1
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/modAL/models/learners.py", line 79, in init
X_training, y_training, bootstrap_init, **fit_kwargs)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/modAL/models/base.py", line 63, in init
self._fit_to_known(bootstrap=bootstrap_init, **fit_kwargs)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/modAL/models/base.py", line 106, in _fit_to_known
self.estimator.fit(self.X_training, self.y_training, **fit_kwargs)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/keras/wrappers/scikit_learn.py", line 209, in fit
return super(KerasClassifier, self).fit(x, y, **kwargs)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/keras/wrappers/scikit_learn.py", line 151, in fit
history = self.model.fit(x, y, **fit_args)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/keras/engine/training.py", line 1213, in fit
self._make_train_function()
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/keras/engine/training.py", line 316, in _make_train_function
loss=self.total_loss)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/keras/optimizers.py", line 543, in get_updates
p_t = p - lr_t * m_t / (K.sqrt(v_t) + self.epsilon)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 815, in binary_op_wrapper
y = ops.convert_to_tensor(y, dtype=x.dtype.base_dtype, name="y")
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1039, in convert_to_tensor
return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1097, in convert_to_tensor_v2
as_ref=False)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1175, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 304, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 245, in constant
allow_broadcast=True)
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 283, in _constant_impl
allow_broadcast=allow_broadcast))
File "/home/es712/pythonenvs/tensorflow1.13.1/tensorflow1.13.1/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 454, in make_tensor_proto
raise ValueError("None values not supported.")
ValueError: None values not supported.

from modal.

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.