uctb / UCTB

An Open Source Spatio-Temporal Prediction Package
MIT License
180 stars 42 forks source link

Question with "with_tpe=True" #10

Closed lmx88460725 closed 2 years ago

lmx88460725 commented 3 years ago

Thanks for your great work!

When I create my own dataset with the STMeta method and set the parameter "with_tpe=True", the programming report errors as follow:

Traceback (most recent call last): File "STMeta.py", line 29, in sequence_length=data_loader.train_sequence_len) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/UCTB_limx_new/model_unit/BaseModel.py", line 186, in fit op_names=op_names) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/UCTB_limx_new/model_unit/BaseModel.py", line 91, in _run outputs = self._session.run(output_tensor_list, feed_dict=feed_dict_tf) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1149, in _run str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (64, 1608, 6, 2) for Tensor 'closeness_feature:0', which has shape '(?, ?, 6, 1)'

Should I change any parameters anywhere?

Thanks again and look forward to your reply.

Best regards

Liyue-Chen commented 2 years ago

Thanks for your great work!

When I create my own dataset with the STMeta method and set the parameter "with_tpe=True", the programming report errors as follow:

Traceback (most recent call last): File "STMeta.py", line 29, in sequence_length=data_loader.train_sequence_len) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/UCTB_limx_new/model_unit/BaseModel.py", line 186, in fit op_names=op_names) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/UCTB_limx_new/model_unit/BaseModel.py", line 91, in _run outputs = self._session.run(output_tensor_list, feed_dict=feed_dict_tf) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1149, in _run str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (64, 1608, 6, 2) for Tensor 'closeness_feature:0', which has shape '(?, ?, 6, 1)'

Should I change any parameters anywhere?

Thanks again and look forward to your reply.

Best regards

Hi~ lmx88460725

This error occurs because the input_dim (i.e., the dimension of crowd flow features) is fixed to 1 currently. If the "with_tpe" is set to True, the last axis of closeness_feature will be 2 (one is crowd flow data and the other is temporal embedding).

To avoid this, you can set the "with_tpe" to False, which will not use the temporal embedding. We will soon add a parameter, namely input_dim to the STMeta model, that enables multiple dimension inputs.

Thank you for your valuable feedback.

Best regards

Liyue-Chen commented 2 years ago

Thanks for your great work!

When I create my own dataset with the STMeta method and set the parameter "with_tpe=True", the programming report errors as follow:

Traceback (most recent call last): File "STMeta.py", line 29, in sequence_length=data_loader.train_sequence_len) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/UCTB_limx_new/model_unit/BaseModel.py", line 186, in fit op_names=op_names) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/UCTB_limx_new/model_unit/BaseModel.py", line 91, in _run outputs = self._session.run(output_tensor_list, feed_dict=feed_dict_tf) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 950, in run run_metadata_ptr) File "/usr/local/anaconda3/envs/py36limx2/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1149, in _run str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (64, 1608, 6, 2) for Tensor 'closeness_feature:0', which has shape '(?, ?, 6, 1)'

Should I change any parameters anywhere?

Thanks again and look forward to your reply.

Best regards

We're glad to tell you STMeta now can support multiple dimension inputs. Please set the input_dim to 2 if the "with_tpe" is True. Here is the example:

STMeta_obj = STMeta(num_node=data_loader.station_number, num_graph=graph_obj.LM.shape[0], external_dim=data_loader.external_dim, closeness_len=args['closeness_len'], period_len=args['period_len'], trend_len=args['trend_len'], input_dim=2 if args['with_tpe'] else 1, gcn_k=int(args.get('gcn_k', 0)), gcn_layers=int(args.get('gcn_layers', 0)), gclstm_layers=int(args['gclstm_layers']), num_hidden_units=args['num_hidden_units'], num_dense_units=args['num_filter_conv1x1'],

temporal attention parameters

                tpe_dim=data_loader.tpe_dim,
                temporal_gal_units=args.get('temporal_gal_units'),
                temporal_gal_num_heads=args.get('temporal_gal_num_heads'),
                temporal_gal_layers=args.get('temporal_gal_layers'),
                # merge parameters
                graph_merge_gal_units=args['graph_merge_gal_units'],
                graph_merge_gal_num_heads=args['graph_merge_gal_num_heads'],
                temporal_merge_gal_units=args['temporal_merge_gal_units'],
                temporal_merge_gal_num_heads=args['temporal_merge_gal_num_heads'],
                # network structure parameters
                st_method=args['st_method'],  # gclstm
                temporal_merge=args['temporal_merge'],  # gal
                graph_merge=args['graph_merge'],  # concat
                build_transfer=args['build_transfer'],
                lr=float(args['lr']),
                code_version=code_version,
                model_dir=model_dir_path,
                gpu_device=current_device)
lmx88460725 commented 2 years ago

Thanks very much!