Comments (3)
At this point, i think this error is due to tensorflow removing the support from list inputs. I tried to fix it by giving it a list of numpy arrays as Xtrain but i got a new error.
Xtrain = []
for k in range(len(features)):
Xtrain.append([])
Xvalid = []
for k in range(len(features)):
Xvalid.append([])
for k in range(len(features)):
Xtrain[k].append(np.asarray(df_train[features].values[:,k]))
error:
y_traincat shape 480000
y_traincat shape (480000, 2)
Epoch 1/3
467/469 [============================>.] - ETA: 0s - loss: 0.4757
IndexError Traceback (most recent call last)
in
----> 1 run(1)
in run(fold)
151 print(f'y_traincat shape {ytrain_cat.shape}')
152
--> 153 model.fit(Xtrain,ytrain_cat, validation_data = (Xvalid, yvalid_cat), verbose = 1, batch_size =1024, epochs = 3)
154
155
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, *args, **kwargs)
64 from tensorflow.python.ops import math_ops
65 from tensorflow.python.ops import sparse_ops
---> 66 from tensorflow.python.ops import summary_ops_v2
67 from tensorflow.python.ops import variables
68 from tensorflow.python.ops.ragged import ragged_concat_ops
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
860 A more detailed description of unpacking behavior for iterator types
861 (Dataset, generator, Sequence) is given below.
--> 862 y: Target data. Like the input data x
,
863 it could be either Numpy array(s) or TensorFlow tensor(s).
864 It should be consistent with x
(you cannot have Numpy inputs and
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, *args, **kwargs)
64 from tensorflow.python.ops import math_ops
65 from tensorflow.python.ops import sparse_ops
---> 66 from tensorflow.python.ops import summary_ops_v2
67 from tensorflow.python.ops import variables
68 from tensorflow.python.ops.ragged import ragged_concat_ops
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in evaluate(self, x, y, batch_size, verbose, sample_weight, steps, callbacks, max_queue_size, workers, use_multiprocessing, return_dict)
1044 data_adapter.unpack_x_y_sample_weight(validation_data))
1045
-> 1046 with self.distribute_strategy.scope(),
1047 training_utils.RespectCompiledTrainableState(self):
1048 # Creates a tf.data.Dataset
and handles batch and epoch iteration.
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py in init(self, x, y, sample_weight, batch_size, steps_per_epoch, initial_epoch, epochs, shuffle, class_weight, max_queue_size, workers, use_multiprocessing, model)
1097 if steps_per_execution is None:
1098 self._steps_per_execution = 1
-> 1099 self._steps_per_execution_value = 1
1100 else:
1101 self._steps_per_execution = steps_per_execution
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py in select_data_adapter(x, y)
955
956 ALL_ADAPTER_CLS = [
--> 957 ListsOfScalarsDataAdapter, TensorLikeDataAdapter,
958 GenericArrayLikeDataAdapter, DatasetAdapter,
959 GeneratorDataAdapter, KerasSequenceAdapter, CompositeTensorDataAdapter,
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py in (.0)
955
956 ALL_ADAPTER_CLS = [
--> 957 ListsOfScalarsDataAdapter, TensorLikeDataAdapter,
958 GenericArrayLikeDataAdapter, DatasetAdapter,
959 GeneratorDataAdapter, KerasSequenceAdapter, CompositeTensorDataAdapter,
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py in can_handle(x, y)
617 @staticmethod
618 def can_handle(x, y=None):
--> 619 handles_x = ListsOfScalarsDataAdapter._is_list_of_scalars(x)
620 handles_y = True
621 if y is not None:
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py in _is_list_of_scalars(inp)
628 return True
629 if isinstance(inp, (list, tuple)):
--> 630 return ListsOfScalarsDataAdapter._is_list_of_scalars(inp[0])
631 return False
632
~/anaconda3/envs/ml/lib/python3.8/site-packages/tensorflow/python/keras/engine/data_adapter.py in _is_list_of_scalars(inp)
628 return True
629 if isinstance(inp, (list, tuple)):
--> 630 return ListsOfScalarsDataAdapter._is_list_of_scalars(inp[0])
631 return False
632
IndexError: list index out of range
from approachingalmost.
The book used tf==1.15
from approachingalmost.
I get a Value Error on running the above code
ValueError: A Concatenate
layer should be called on a list of at least 2 inputs
ValueError Traceback (most recent call last)
in
64
65 if name == "main":
---> 66 run(0)
67 run(1)
68 run(2)
in run(fold)
25
26 # create tf.keras model
---> 27 model = create_model(df,features)
28
29 # our features are lists of lists
in create_model(data, catcols)
47
48 # concatenate all output layers
---> 49 x = layers.Concatenate()(outputs)
50
51 # add a batchnorm layer
~/miniconda3/envs/ml/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in call(self, *args, **kwargs)
895 # Build layer if applicable (if the build
method has been
896 # overridden).
--> 897 self._maybe_build(inputs)
898 cast_inputs = self._maybe_cast_inputs(inputs)
899
~/miniconda3/envs/ml/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
2414 # operations.
2415 with tf_utils.maybe_init_scope(self):
-> 2416 self.build(input_shapes) # pylint:disable=not-callable
2417 # We must set also ensure that the layer is marked as built, and the build
2418 # shape is stored since user defined build functions may not be calling
~/miniconda3/envs/ml/lib/python3.7/site-packages/tensorflow/python/keras/utils/tf_utils.py in wrapper(instance, input_shape)
314 if input_shape is not None:
315 input_shape = convert_shapes(input_shape, to_tuples=True)
--> 316 output_shape = fn(instance, input_shape)
317 # Return shapes from fn
as TensorShapes.
318 if output_shape is not None:
~/miniconda3/envs/ml/lib/python3.7/site-packages/tensorflow/python/keras/layers/merge.py in build(self, input_shape)
491 # Used purely for shape validation.
492 if not isinstance(input_shape[0], tuple) or len(input_shape) < 2:
--> 493 raise ValueError('A Concatenate
layer should be called '
494 'on a list of at least 2 inputs')
495 if all(shape is None for shape in input_shape):
from approachingalmost.
Related Issues (20)
- Can't get code on page 137 to work
- In `adult citizens` problem you don't include `education.num` in number column
- Why don't you use average auc (but list of auc's)?
- Is the keras model in adult sensus data realy is the best? HOT 1
- Typo on page 5
- Hard to differentiate code from comments HOT 1
- code missing create_folds.py missing HOT 1
- numpy version is conflicting HOT 3
- Error while loading the vectors of crawl-300d-2M.vec
- csv files used in the book HOT 3
- fillna() issue
- Correction in Page 37
- keras model translation to pytorch doesn't perform as expected
- Arranging machine learning projects as GH template HOT 2
- load_vectors - Memory Issue
- a version of the book with an index or table of contents?
- Hello author, I encountered the following installation package error when I used your environment.yml to create the environment. I tried to update conda, pip and the corresponding mirror source, but still failed to solve it. How can I solve this problem?
- Supervised Learning - First example MNIST data HOT 1
- Can I help you translate the book into Chinese? HOT 4
- Bug in page 213
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from approachingalmost.